How to remove all the properties (INVOCATION/INBOUND/OUTBOUND/SESSION) in a specific scope in mule - mule

I am having a problem where my rabbit mq message put is erroring and it does not tell me what the root cause for the put failure is. Looking at stackoverflow, I see that my problem is identical to what was reported here-to store a message in rabbitmq from mule-as far as exception goes.
Now I am trying to find out if there is a way to remove all the properties present in the message or if the removal can be performed per scope (i.e. INVOCATION/INBOUND/OUTBOUND/SESSION). Reason being, I dont know which property, if at all, is causing this.
I did look at <remove-property> & <message-properties-transformer> but they work on a specific property only (& not all).

are you sure that <remove-property> works on specific properties only? i recall using this transformer with a wildcard to achieve something similar to what you are trying to do:
<remove-property propertyName="*" doc:name="Property"/>

You could do it with this inside a Groovy Transformer:
import org.mule.api.transport.PropertyScope
message.getPropertyNames(PropertyScope.OUTBOUND).each {p -> message.removeProperty(p, PropertyScope.OUTBOUND)}
I would be looking at scopes OUTBOUND and SESSION, as the other scopes shouldn't be propagated over a transport boundary.

Related

advice handler on aws outbound channel adapter

In the past I have been able to apply advice chain handlers on different outbound channel adapters. I am trying to do the same on int-aws:s3-outbound-channel-adapter but its not allowing that. Does this component not allows this behavior. Basically I am interested in finding out when the adapter completes the upload of a file to S3.
<int-aws:s3-outbound-channel-adapter
id="s3-outbound" channel="files" bucket="${s3.bucket}"
multipart-upload-threshold="5192" remote-directory="${s3.remote.dir}"
accessKey="${accessKey}" secretKey="${secretKey}">
THIS DOESNT WORKS - throws an error !!!
<int:request-handler-advice-chain>
</int:request-handler-advice-chain>
</int-aws:s3-outbound-channel-adapter>
Right, that isn't allowed by the XSD. Feel free to raise a JIRA on the matter.
But that doesn't matter that it doesn't work at all.
If you are on Spring Integration 4.x already you can move that <int-aws:s3-outbound-channel-adapter> to the Java & Annotation configuration using #Bean and #ServiceActivator for the AmazonS3MessageHandler.
Where #ServiceActivator has adviceChain attribute to specify bean references to your Advices.
... or you can do that using generic <int:outbound-channel-adapter> and specify AmazonS3MessageHandler as raw <bean> for the ref of the first one.
HTH

Mule Web Service Consumer Warning : Operation Messages With More then 1 Part Are Not Supported

Hi I am working with Mule Web Service Consumer and i was trying to call operation with Multiple Parameters it is warning me that
Warning : Operation Messages With More then 1 Part Are Not Supported
I just want to pass multiple parameters to access my SOAP method to achieve the task.
Is this the problem with Web Service Consumer or is their any way to deal with this.
I'm afraid this is a known limitation of the web services consumer. However you can accomplish this with the cxf component.
I having the same issue and found some information around it ...
There is a improvement logged in JIRA, may help if you vote for it :)
This link suggests that you can still use WSConsumer but need to do some hand crafting of the request XML ... I could not understand what that exactly it meant so if anyone has an example on it would be great
PS: The problem I had with using CXF component is that it does not play well with the new Dataweave transformer as the Dataweave needs to be placed within the response block and from there it cannot datasense the response coming out from the CXF component
The Solution here is very simple. You just have to comment other messages and then load metadata for non-commented message (for one which you're trying to load metadata). Repeat this procedure for all the other messages and you're good to go.
Hope this helps !

Is it safe to rely on session variables to store information to be shared between multiple asynchronous flows?

I have a couple of flows that rely on session variables that are generated in one flow and then passed to the other. Is it safe to rely on session variables used by two asynchronous flows? I guess I don't fully understand the scope of 'sessionVars' in a mule application or in a given mule message.
The mule session has nothing to do with the Java EE session that is shared across threads. The mule session is part of the MuleMessage and how they works is explained here, therefor if you want to share something across multiple flows processing the same message that is the way to go.
If instead you are looking into a way to store a value from a flow processing the message A and pick that value from a flow processing the message B you should consider store this value into the objectstore
I am pretty sure that session variables are returned to http endpoints that are request-response. This could expose sensitive data. I am trying to locate the original mention and official mitigation strategy but have yet to locate it again.
But an easy solution is to remove them at return point of a flow
Edit:
Found the thing I was looking for...
`
<http:connector name="NoSessionConnector">
<service-overrides sessionHandler="org.mule.session.NullSessionHandler"/>
</http:connector>
`
found here under 'HTTP Response Header'
http://www.mulesoft.org/documentation/display/current/HTTP+Transport+Reference
Or, you can also create a custom SessionHandler

Apache-ODE ProcessManagement

I can access this API/WS through
http://localhost:8080/ode/processes/ProcessManagement?wsdl.
I would like to get the Process Info of a Process through this service and active it.
The serivce has the matching operations getProcessInfo and activate.
With listAllProcesses I get all Processes of a delpoyed package.
For getProcessInfo/activate I need the Process pid.
I get a <ns:pid>, using this gets me a load of Exceptions.
Using the name of the process and other stuff I receive earlier doesn't work either.
The pid is of type QName, perhaps thats the root of the problem.
However I don't now how to typecast here.
(Tried all with the eclipse Web Services Explorer and soapUI)
question: How does a proper request for both Operations look like?
When I try to consume the webservice with axi2 via eclipse, there is a undeclared variable local in the AnySimpleType class. I'm not keen on using the service this way.
But since I'm already writing a Client for the DeploymentService I thought about this approach.
question: How do I properly access the ProcessManagement?
EDIT: I have a simular problem with the DeploymentService and the undeploy Operation.
EDIT2: I figured the Problem with the DeploymentService undeploy out.
I had to get the Packagename as String. Then a made a javax.xml.namespace.QName out of it. Then I used the setPackageName of said undeploy operation.
Answer to question number 1:
soapUI with listAllProcesses returns
<ns:pid>{ode/bpel/unit-test}HelloWorld2-1</ns:pid>
getProcessInfo wants
<pmap:getProcessInfo>
<pid>?</pid>
</pmap:getProcessInfo>
Now I replaced <pid>?</pid> with
<pid xmlns:odetest="http://ode/bpel/unit-test">odetest:HelloWorld2-1</pid>
and it worked like a charm.
I remember that there was an issue with parameter ordering when using the Axis2 generated WSDL. Could you try if building a request against the original WSDL located at http://localhost:8080/ode/deployment/services/ProcessManagement works?
EDIT: Now that I got the question correctly, the problem is that ODE expects the QName to be serialized differently, i.e. in the XML way instead of the Java way. Thus, instead of <ns:pid>{ode/bpel/unit-test}HelloWorld2-1</ns:pid> the correct notation is <ns:pid xmlns:odetest="ode/bpel/unit-test">odetest:HelloWorld2-1</ns:pid>.

How can I easily add and remove message conversion logic into a processing flow in Spring Integration?

I've been playing with Spring integration, and I can't see how best to solve the following problem.
Say I have XML messages arriving onto a channel. These messages may have arbitrary structure, and I want to convert them to my canonical form, so I think I want to write custom converters for each type of structure, so that I can do whatever processing and error-checking I want.
The obvious thing is to wire up a router to have a look at the messages and route to an appropriate converter, but I think this means I need to hard-code the processing flow onto a channel pointing at each converter.
I'd like to avoid hard-configuring in the different converters and routing logic, and the alternative that springs to mind is to have a set of converters that implement some kind of boolean canHandle(message), so that we just show the message to each converter until one 'claims' the message or we run out. This way, it seems like I might be able to annotate the converters into the configuration without actually modifying the processing flow.
I'm new to Spring integration and I may well be mis-thinking this. Is there a stock way to do this in Spring integration, have I missed something or am I going about it all wrong?
There are a number of ways to do this. The first one that came to mind is a recipient list router with selector expressions:
<recipient-list-router id="simpleDynamicRouter" input-channel="simpleDynamicInput">
<recipient selector-expression="#handler1.canHandle(payload)" channel="toHandler1"/>
<recipient selector-expression="#handler2.canHandle(payload)" channel="toHandler2"/>
<recipient selector-expression="#handler3.canHandle(payload)" channel="toHandler3"/>
</recipient-list-router>
<transformer ... ref="handler1" />
<transformer ... ref="handler2" />
<transformer ... ref="handler3" />
Where handler1 etc are <bean/>s with your implementation, and canHandle() method.
Another option is to write your own custom dynamic router; there's an example of how to do that here https://github.com/SpringSource/spring-integration-samples/tree/master/advanced/dynamic-ftp