What's the difference between these 2 Mule flows - mule

<flow name="webserviceFlow1">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:7079/service">
<cxf:jaxws-service doc:name="SOAP" enableMuleSoapHeaders="false" serviceClass="MyService"/>
</http:inbound-endpoint>
<component class="MyServiceImpl" />
</flow>
And
<flow name="webserviceFlow1">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:7079/service"/>
<cxf:jaxws-service doc:name="SOAP" enableMuleSoapHeaders="false" serviceClass="MyService"/>
<component class="MyServiceImpl" />
</flow>

If the flow stays as it is in your question, they're functionally equivalent.
If you would want to make this flow also accessible for direct requests, say over the VM transport, by using a <composite-source>, then you'll want to circumscribe the cxf:jaxws-service to the http:inbound-endpoint so the CXF logic doesn't kick in, as shown here:
<flow name="webserviceFlow1">
<composite-source>
<vm:inbound-endpoint path="directAccess" />
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:7079/service">
<cxf:jaxws-service doc:name="SOAP" enableMuleSoapHeaders="false" serviceClass="MyService"/>
</http:inbound-endpoint>
</composite-source>
<component class="MyServiceImpl" />
</flow>

Related

Mule ESB: Not able to control the flows from flow1 to flow 2

I have a ServiceFlow and a FileFlow. As soon as the ServiceFlow (Flow1) is triggered, FileFlow (Flow2) should take all the files and process them.
Making the initial state as stopped in Flow2 works only for the first time until Mule server started i.e., for the first triggered execution. Once the flow reaches the first trigger, if I try to keep some files in file:inbound-endpoint it starts processing the files.
But my scenario is based on each trigger only, so the second file has to pick the file. Please help me how to control this in Flow2.
I'm using the below code
<flow name="serviceFlow" doc:name="Flow1">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8081" doc:name="HTTP" contentType="text/xml"
mimeType="text/xml" />
<set-payload value="'Started Processing'" doc:name="Set Payload" />
<async doc:name="Async">
<expression-component doc:name="Expression">
app.registry.FileFlow.start();
</expression-component>
</async>
</flow>
<flow name="FileFlow" doc:name="Flow2" initialState="stopped" >
<file:inbound-endpoint responseTimeout="10000" doc:name="File" path="C:\Users\Desktop\IN"/>
<batch:execute name="businessBatch1" doc:name="Batch Execute"/>
</flow>
Using Mule version: 3.5.1
What I can suggest you is to put a <expression-component doc:name="Expression">app.registry.FileFlow.stop();</expression-component> at the end of second flow so after the second flow is executed it will again make it's initial state "stopped" so that you can trigger the first flow again without fear since the flow2 is stopped.
<flow name="serviceFlow" doc:name="Flow1">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8081" doc:name="HTTP" contentType="text/xml"
mimeType="text/xml" />
<set-payload value="'Started Processing'" doc:name="Set Payload" />
<async doc:name="Async">
<expression-component doc:name="Expression">
app.registry.FileFlow.start();
</expression-component>
</async>
</flow>
<flow name="FileFlow" doc:name="Flow2" initialState="stopped" >
<file:inbound-endpoint responseTimeout="10000" doc:name="File" path="C:\Users\Desktop\IN"/>
<batch:execute name="businessBatch1" doc:name="Batch Execute"/>
<expression-component doc:name="Expression">
app.registry.FileFlow.stop();
</expression-component>
</flow>

Async block makes all flow-refs inside async?

Consider the following case:
I have a webservice that starts importing stuff from a source. I'd like to return 200 OK to the caller as soon as the call is accepted.
There few different flows that need to executed in the right order.
<flow name="startImport" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="startImport"/>
<async>
<flow-ref name="Country" />
<flow-ref name="Account" />
<flow-ref name="Contact" />
</async>
</flow>
Well, this doesn't work, as all of the flows are executed at once.
How about wrapping it in an another flow like this?
<flow name="startImport" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="startImport"/>
<async>
<flow-ref name="startImport2" />
</async>
</flow>
<flow name="startImport2" processingStrategy="synchronous" >
<processor-chain>
<flow-ref name="Country" />
<flow-ref name="Account" />
<flow-ref name="Contact" />
</processor-chain>
</flow>
Nope, still the same result!
How can I stop the async-block making all the other flow-refs from turning async as well? I only want the first call to start asynchronously!
Private flows invoked via flow-ref will pick up the synchronicity of the in-flight event.
To change this you can change the processingStrategy of the flows you want to execute synchronously. Example:
<flow name="Country" processingStrategy="synchronous">
</flow>
Well, I ended up removing the flow refs and using vm-endpoints instead, like this:
<flow name="startImport" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="startImport"/>
<async>
<vm:outbound-endpoint exchange-pattern="one-way" doc:name="VM" path="import-all.service.in"/>
</async>
</flow>
<flow name="startImport2" processingStrategy="synchronous" >
<vm:outbound-endpoint exchange-pattern="one-way" doc:name="VM" path="import-all.service.in"/>
<flow-ref name="Country" />
<flow-ref name="Account" />
<flow-ref name="Contact" />
</flow>
Now it works like I'd expect it to work, it quickly returns from the call and lets the async flow do the heavy lifting.

Mule: How to do NTLM authentication in Mule ESB?

How to do NTLM authentication in Mule (Mule Studio 3.5)?
On Internet i have found following ways:
<http:connector name="HTTP_HTTPS" ... proxyHostname="..." proxyPort="80" proxyPassword="..." proxyUsername="Castor.Acer">
<spring:property name="proxyNtlmAuthentication" value="true"/>
</http:connector>
<http:connector name="httpConnector" proxyHostname="someHost" proxyPort="8080"
proxyNtlmAuthentication="true" proxyUsername="someUser" proxyPassword="somePass" />
But none worked for me, or am i configuring it properly?
Presently i am using it as following:
<mule>
<http:connector name="HTTPO" proxyHostname="10.91.17.170" proxyPort="81" proxyUsername="administrator" proxyPassword="Psw0rd123"
doc:name="HTTP\HTTPS">
<spring:property name="proxyNtlmAuthentication" value="true"/>
</http:connector>
<flow name="testPraveenFlow1" doc:name="testPraveenFlow1">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:81/Orcha" doc:name="HTTP"/>
<custom-transformer class="com.CreateBook" doc:name="Java"/>
<http:outbound-endpoint exchange-pattern="request-response" method="POST" contentType="text/xml" doc:name="HTTP" address="http://10.91.17.170:81/Orch2012/Orch.svc/jobs" connector-ref="HTTPO"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
Output:
401 - Unauthorized: Access is denied due to invalid credentials.</h2>
You do not have permission to view this directory or page using the credentials that you supplied.

Issue with mule vmconnector to receive from more than 20 one-way inbound endpoints

I am having the following problem concerning asynchronous (or one-way) vm inbound endpoints. In the tests below, it seems that the number of one-way inbound endpoints is limited to 20 per vmconnector. My question is: Is there a setting on the vmconnector or a way programmatically to configure the vmconnector to remove this limitation?
I am using Mule 3.3.1 CE.
Thanks.
test1 (will fail to reach secondFlow unless the 21nd endpoint uses vmConn2):
<mule ..>
<stdio:connector name="stdioConn" messageDelayTime="1000" promptMessage="prompt >"/>
<vm:connector name="vmConn"/>
<vm:connector name="vmConn2"/>
<flow name="FirstFlow">
<stdio:inbound-endpoint system="IN" connector-ref="stdioConn"/>
<vm:outbound-endpoint exchange-pattern="one-way" path="path21" connector-ref="vmConn"/>
</flow>
<flow name="SecondFlow">
<composite-source doc:name="Composite Source">
<vm:inbound-endpoint exchange-pattern="one-way" path="path1" connector-ref="vmConn"/>
<vm:inbound-endpoint exchange-pattern="one-way" path="path2" connector-ref="vmConn"/>
<vm:inbound-endpoint exchange-pattern="one-way" path="path3" connector-ref="vmConn"/>
....
<vm:inbound-endpoint exchange-pattern="one-way" path="path20" connector-ref="vmConn"/>
<vm:inbound-endpoint exchange-pattern="one-way" path="path21" connector-ref="vmConn"/>
</composite-source>
<logger message="MESSAGE RECEIVED!" level="INFO" doc:name="Logger"/>
</flow>
test2 (same test with 21 flows):
<flow name="Flow1" >
<stdio:inbound-endpoint system="IN" connector-ref="stdioConn"/>
<vm:outbound-endpoint exchange-pattern="one-way" path="path21" connector-ref="vmConn" />
</flow>
<flow name="Flow2">
<vm:inbound-endpoint exchange-pattern="one-way" path="path1" connector-ref="vmConn" doc:name="VM" />
<logger message="MESSAGE RECEIVED!" level="INFO" doc:name="Logger" />
</flow>
<flow name="Flow3">
<vm:inbound-endpoint exchange-pattern="one-way" path="path2" connector-ref="vmConn" doc:name="VM" />
<logger message="MESSAGE RECEIVED!" level="INFO" doc:name="Logger" />
</flow>
...
<flow name="Flow21">
<vm:inbound-endpoint exchange-pattern="one-way" path="path20" connector-ref="vmConn" doc:name="VM" />
<logger message="MESSAGE RECEIVED!" level="INFO" doc:name="Logger" />
</flow>
<flow name="Flow22">
<vm:inbound-endpoint exchange-pattern="one-way" path="path21" connector-ref="vmConn" doc:name="VM" />
<logger message="MESSAGE RECEIVED!" level="INFO" doc:name="Logger" />
</flow>
Any vm connector has a thread pool of message receivers. Once the receiver are exhausted new vm inbound endpoint want be able to process messages.
To address it you should increase the number of message receivers configuring threading profiles properly

Mule throttling on a backend service

I have a back end service that I need to throttle access to. I'm trying to use the approach described here: http://blogs.mulesoft.org/synchronous-and-asynchronous-throttling-2/
I started with a simple pass through flow that receives a SOAP request and forwards it. When I hit this using the SOAPUI utility, I get the expected response in a second or two.
<http:connector name="httpConnector" doc:name="HTTP\HTTPS">
<receiver-threading-profile maxThreadsActive="1" maxBufferSize="100" />
</http:connector>
<jms:activemq-connector name="amqConnector" brokerURL="tcp://localhost:61616" specification="1.1" doc:name="AMQ" />
<flow name="Flow1" processingStrategy="synchronous" doc:name="Flow1">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8088" path="test" doc:name="HTTP"
mimeType="text/xml" encoding="UTF-8" connector-ref="httpConnector"/>
<http:outbound-endpoint
address="http://dnbdirect-api.dnb.com/DnBAPI-11"
exchange-pattern="request-response" doc:name="HTTP" mimeType="text/xml"/>
</flow>
If I then move the outbound call to a separate flow and add in the request-reply block, the behavior changes. I get no response back (nor do I get the "After queue" message from the logger) and SOAPUI eventually times out.
<http:connector name="httpConnector" doc:name="HTTP\HTTPS">
<receiver-threading-profile maxThreadsActive="1" maxBufferSize="100" />
</http:connector>
<jms:activemq-connector name="amqConnector" brokerURL="tcp://localhost:61616" specification="1.1" doc:name="AMQ" />
<flow name="Flow1" processingStrategy="synchronous" doc:name="Flow1">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8088" path="test" doc:name="HTTP"
mimeType="text/xml" encoding="UTF-8" connector-ref="httpConnector"/>
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="AMQ_SCHEDULED_DELAY" value="5000"/>
</message-properties-transformer>
<logger message="Before queue" level="INFO"/>
<request-reply>
<jms:outbound-endpoint queue="request" connector-ref="amqConnector"></jms:outbound-endpoint>
<jms:inbound-endpoint queue="response" connector-ref="amqConnector"></jms:inbound-endpoint>
</request-reply>
<logger message="After queue" level="INFO"/>
</flow>
<flow name="flow2" doc:name="Flow2">
<jms:inbound-endpoint queue="request" connector-ref="amqConnector" doc:name="JMS"/>
<http:outbound-endpoint
address="http://dnbdirect-api.dnb.com/DnBAPI-11"
exchange-pattern="request-response" doc:name="HTTP" mimeType="text/xml" />
</flow>
The throttling behavior works as I see the delays if I pull out the call to the back end service. But I can't get it to work with the service call there.
What am I missing?
I found that the message's payload will be "ArrayList" after "request-reply".
so i add a java component to split it, then the result will be corrected.
#Override
public Object onCall(MuleEventContext eventContext) throws Exception {
MuleMessage message = eventContext.getMessage();
//int groupSize = message.getCorrelationGroupSize();
//System.out.println("############# correlationGroupSize: " + groupSize);
Object payload = message.getPayload();
if (payload != null && payload instanceof ArrayList) {
//message.setPayload(((ArrayList)payload).get(0));
return ((ArrayList)payload).get(0);
}
return message.getPayload();
}
the completed flow is:
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="AMQ_SCHEDULED_DELAY" value="10000"/>
</message-properties-transformer>
<request-reply storePrefix="mainFlow">
<jms:outbound-endpoint queue="request" connector-ref="amqConnector" doc:name="JMS"></jms:outbound-endpoint>
<jms:inbound-endpoint queue="response" connector-ref="amqConnector" doc:name="JMS"></jms:inbound-endpoint>
</request-reply>
<component class="com.neusoft.fx.JmsMessageTransformer" doc:name="Java"/>
<message-properties-transformer doc:name="Set Content Type">
<delete-message-property key="Content-type" />
<add-message-property key="Content-Type" value="text/xml"/>
</message-properties-transformer>
<logger message="----- LOGGER ----- after #[groovy:message.toString()]" level="INFO" doc:name="Logger" />
</flow>
Try adding the following before the HTTP outbound endpoint in flow2:
<copy-properties propertyName="MULE_*"/>