Ban Mule ESB from blocking some requests - java

Some times (very frequent) mule ESB blocks some of SOAP Requests. How can i Stop Mule from doing that? i don't know what is the reason of blocking.
this is how i have configured http-listener in mule config :
<http:listener-config name="HTTP_listener" host="${MachineName}" port="${InboundPort}" doc:name="HTTP listener Configuration" />
<flow name="etryFlow" >
<http:listener allowedMethods="POST" config-ref="HTTP_listener" path="/{name}" doc:name="HTTP"/>
<set-payload value="#[app.registry.pairFactory.createInputStreamWithStringKeyInstance(message.inboundProperties['http.uri.params']['name'],payload))]" />
<jms:outbound-endpoint connector-ref="jms-connector" ref="UnsortedOrders" />
<logger level="INFO" doc:name="Logger" message="****Entry****" />
</flow>
note : the banned requests are converted into BlockingTransferInputStream instead of BufferInputStream.
thank you.
** EDIT **
this is createInputStreamWithStringKeyInstance implementation :
public static Pair<String, byte[]> createByteArrayWithStringKeyInstance(String key, byte value[]) throws IOException {
return new Pair<String, byte[]>(key, value);
}
and Pair.java is a simple Serializable Class (same as JavaFX.Pair)
Note : The input is a SOAP XML
--EDIT --
This is mule config file :
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:bpm="http://www.mulesoft.org/schema/mule/bpm"
xmlns:client="http://www.mulesoft.org/schema/mule/client"
xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:management="http://www.mulesoft.org/schema/mule/management"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/3.2/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.2/mule-jms.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.2/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/bpm http://www.mulesoft.org/schema/mule/bpm/3.2/mule-bpm.xsd
http://www.mulesoft.org/schema/mule/client http://www.mulesoft.org/schema/mule/client/3.2/mule-client.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.mulesoft.org/schema/mule/management http://www.mulesoft.org/schema/mule/management/current/mule-management.xsd ">
<jms:activemq-connector name="jms-connector" brokerURL="${BrokerURL}" disableTemporaryReplyToDestinations="true" specification="1.1"/>
<jms:endpoint connector-ref="jms-connector" exchange-pattern="one-way" name="UnsortedOrders" queue="UnsortedOrders"/>
<jms:endpoint connector-ref="jms-connector" exchange-pattern="one-way" name="DestinationEMC" queue="DestinationEMC" />
<jms:endpoint connector-ref="jms-connector" exchange-pattern="one-way" name="DestinationOriginal" queue="DestinationOriginal"/>
<management:jmx-default-config>
<management:credentials>
<spring:entry key="admin" value="admin"/>
</management:credentials>
</management:jmx-default-config>
<spring:beans>
<context:property-placeholder location="classpath:Application.properties"/>
<spring:bean name="NoFactsBean" class="java.util.ArrayList" scope="singleton"/>
<spring:bean id="objectStore" class="org.mule.util.store.QueuePersistenceObjectStore"/>
<spring:bean id ="requestBean" class="com.hamgam.hit.esb.bean.RequestBean" factory-method="getInstance" scope="singleton"/>
</spring:beans>
<message-properties-transformer name="contentTypeTextXML">
<add-message-property key="Content-Type" value="text/xml;charset=UTF-8;" />
</message-properties-transformer>
<http:listener-config name="HTTP_listener" host="${MachineName}" port="${InboundPort}" doc:name="HTTP listener Configuration" />
<flow name="etryFlow">
<http:listener allowedMethods="POST" parseRequest="false" config-ref="HTTP_listener" path="/{name}" doc:name="HTTP" />
<object-to-byte-array-transformer/>
<expression-component>
payload = app.registry.requestBean.createServiceRequest(message.inboundProperties['http.uri.params']['name'],payload);
</expression-component>
<jms:outbound-endpoint connector-ref="jms-connector" ref="UnsortedOrders" />
<logger level="INFO" doc:name="Logger" message="****#[payload] Enters Entry****" />
</flow>
<flow name="consumeRequestsFlow" >
<jms:inbound-endpoint ref="UnsortedOrders" connector-ref="jms-connector" />
<logger level="INFO" doc:name="Logger" message="**** #[payload] Enters consumeRequestsFlow ****" />
<choice doc:name="Choice">
<when expression="#[app.registry.requestBean.isEMCRequired(payload)]">
<jms:outbound-endpoint connector-ref="jms-connector" ref="DestinationEMC" />
</when>
<otherwise>
<jms:outbound-endpoint connector-ref="jms-connector" ref="DestinationOriginal" />
</otherwise>
</choice>
</flow>
<flow name="ConsumeEmcQ">
<jms:inbound-endpoint connector-ref="jms-connector" ref="DestinationEMC" />
<logger level="INFO" doc:name="Logger" message="**** #[payload] Enters ConsumeEmcQ ****" />
<set-payload value="#[app.registry.requestBean.sendToEMC(payload)]" />
<until-successful objectStore-ref="objectStore" maxRetries="${MaximumRetry}" secondsBetweenRetries="${RetryInterval}">
<http:outbound-endpoint address="${ECMURL}" exchange-pattern="one-way">
<transformer ref="contentTypeTextXML"/>
</http:outbound-endpoint>
</until-successful>
</flow>
<flow name="ConsumeOrigQ">
<jms:inbound-endpoint connector-ref="jms-connector" ref="DestinationOriginal" />
<logger level="INFO" doc:name="Logger" message="**** #[payload] Enters ConsumeOriginalQ ****" />
<set-payload value="#[app.registry.requestBean.sendToDestination(payload)]" />
</flow>
<flow name = "EMCResponseFlow" >
<http:inbound-endpoint host="${MachineName}" port="${EMCResponsePort}" exchange-pattern="one-way">
<set-property propertyName="SOAPAction" value="#[message.inboundProperties['SOAPAction']]"/>
<transformer ref="contentTypeTextXML"/>
</http:inbound-endpoint>
<logger level="INFO" doc:name="Logger" message="***EMCResponseEntry****" />
</flow>
</mule>

Assuming createInputStreamWithStringKeyInstance (which you don't describe, so it's really hard to help you) returns an InputStream, Mule ends up building a JMS StreamMessage (per this call).
From the Mule code, you can see it drains the streaming payload into a StreamMessage with this logic:
while ((len = value.read(buffer)) != -1)
{
streamMessage.writeBytes(buffer, 0, len);
}
which is fine, provided the stream returned by createInputStreamWithStringKeyInstance doesn't do any fancy business behind the scene.
Also note that a JMS StreamMessage is probably not what you want. Did you read its Javadoc? It says:
A StreamMessage object is used to send a stream of primitive types in the Java programming language.
I'm pretty sure you instead want to use a JMS BytesMessage. Mule creates such a message if the payload is a byte[] (per the above linked transformation logic) so you'd rather have a <object-to-byte-array-transformer/> right before the jms:outbound-endpoint.

Related

Mule vm:inbound-endpoint not triggered

I have a list which I want to process in paraller, so after calling collection-splitter, I post each record to an outbound-endpoint, but the receiving inbound-endpoint is not been triggered.
Configuration below;
<flow name="ProcessPolledOrders" doc:name="ProcessPolledOrders">
<set-session-variable variableName="fileName" value="#[message.payload.orderBatch.orderSourceName]" />
<set-session-variable variableName="batchId" value="#[message.payload.orderBatch.id]" />
<logger message="************* Item: #[sessionVars.fileName] processing resumed. ***********" level="INFO"/>
<component>
<spring-object bean="PolledOrderSplitter"/>
</component>
<set-session-variable variableName="size" value="#[message.payload.size()"/>
<collection-splitter/>
<set-property propertyName="MULE_CORRELATION_GROUP_SIZE" value="#[sessionVars.size]" />
<set-property propertyName="MULE_CORRELATION_ID" value="#[sessionVars.fileName]" />
<choice>
<when>
<payload-type-filter expectedType="model.Order"/>
<vm:outbound-endpoint exchange-pattern="one-way" path="step2" doc:name="VM"/>
</when>
<otherwise>
<echo-component/>
</otherwise>
</choice>
</flow>
<flow name="PollerOrderProcessingFlow" doc:name="PollerOrderProcessingFlow">
<vm:inbound-endpoint exchange-pattern="one-way" path="step2" doc:name="VM"/>
<logger message="***************** Validating order with id #[message.payload.id] ********************"
level="INFO"/>
<component>
<spring-object bean="PolledOrderValidationComponent"/>
</component>
<collection-aggregator timeout="600000" failOnTimeout="false"
doc:name="Validated Orders Aggregator"/>
<component>
<spring-object bean="BatchOrderUpdateComponent"/>
</component>
<default-exception-strategy>
<flow-ref name="ValidationProcessingExceptionFlow" />
</default-exception-strategy>
</flow>
Are you getting any exception? try to debug and see where the message dropping? I tried similar flow and working fine for me.

Authenticating SOAP service using certificate encodedValue in MULE ESB

I'm provided with a wsdl and have to access certain service (TestMessage) using the authentication credentials provided (username : test-Ser, password: XXXX). The wsdl file was generated from the given config file in C#.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="PProxyEndpoint">
<security>
<message clientCredentialType="UserName" establishSecurityContext="false" />
</security>
</binding>
<binding name="PProxyEndpointSvcCertSpecified">
<security>
<message clientCredentialType="UserName" negotiateServiceCredential="false"
establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://p-cer.test.ca/PService.svc"
binding="wsHttpBinding" bindingConfiguration="PProxyEndpoint"
contract="IPService" name="PProxyEndpoint">
<identity>
<certificate encodedValue="XXXXXXXXXXXXXXXXXX............" />
</identity>
</endpoint>
<endpoint address="http://p-cer.test.ca/PService.svc/SvcCertSpecified"
binding="wsHttpBinding" bindingConfiguration="PProxyEndpointSvcCertSpecified"
contract="IPService" name="PProxyEndpointSvcCertSpecified">
<identity>
<certificate encodedValue="XXXXXXXXXXXXXXXXXX............" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
The authentication code is in C# as below:
private static TestClient AuthUser()
{
TestClient client = new TestClient();
client.ClientCredentials.UserName.UserName = “XXXX”;
client.ClientCredentials.UserName.Password = “XXXXX”;
return client;
}
using (TestClient test = AuthUser())
{
TestListRequestItemWrapper ttt = new TestListRequestItemWrapper();
ttt.RequestItems = new ListRequestItem[1];
ttt.RequestItems[0] = new ListRequestItem();
TestListResponseItemWrapper resp = test.TestList(ttt);
}
I have to do same such thing in java, And I'm unable to do so. Please help.
How can I authenticate SOAP service using certificate encoded value in JAVA?
My configuration.xml in Mule ESB is as follow
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" basePath="test" doc:name="HTTP Listener Configuration"/>
<spring:beans>
<spring:bean name="myPasswordCallback" class="com.org.message.PasswordCallback"/>
</spring:beans>
<spring:beans>
<spring:bean id="wss4jInConfiguration" name="Bean" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<spring:constructor-arg>
<spring:map>
<spring:entry key="action" value="UsernameToken "/>
<spring:entry key="passwordType" value="PasswordText"/>
<spring:entry key="user" value="vha-test.xml"/>
<spring:entry key="passwordCallbackRef" value-ref="myPasswordCallback">
</spring:entry>
</spring:map>
</spring:constructor-arg>
</spring:bean>
</spring:beans>
<http:listener-config name="HTTP_Listener_Configuration_3" host="0.0.0.0" port="8083" doc:name="HTTP Listener Configuration"/>
<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="http://path.svc?wsdl" service="XService" port="XProxyEndpointSvcCertSpecified" serviceAddress="http://path.svc/SvcCertSpecified" doc:name="Web Service Consumer"/>
<flow name="testdemoFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<custom-transformer class="com.org.message.GetMessageExample" doc:name="Java"/>
<response>
<object-to-string-transformer doc:name="Object to String"/>
</response>
<cxf:jaxws-client serviceClass="com.org.IXmlService" doc:name="CXF" operation="GetMessageList" port="IXmlService" soapVersion="1.2">
<!-- <cxf:ws-security>
<cxf:ws-config>
<cxf:property key="action" value="UsernameToken"/>
<cxf:property key="user" value="uname"/>
<cxf:property key="passwordCallbackClass" value="com.org.message.PasswordCallback"/>
<cxf:property key="passwordType" value="PasswordText"/>
</cxf:ws-config>
</cxf:ws-security> -->
<cxf:inInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
<spring:bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<spring:constructor-arg>
<spring:map>
<spring:entry key="action" value="Signature" />
<spring:entry key="signaturePropFile" value="src/main/resources/ws-sign-security.properties" />
</spring:map>
</spring:constructor-arg>
</spring:bean>
</cxf:inInterceptors>
</cxf:jaxws-client>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="Content-type" value="application/soap+xml"/>
<add-message-property key="charset" value="UTF-8"/>
</message-properties-transformer>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8084" method="POST" doc:name="HTTP"/>
</flow>
and below is another configuration.xml I've tried:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" basePath="wsdl" doc:name="HTTP Listener Configuration"/>
<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="http://patyh.svc?wsdl" service="XService" port="XProxyEndpoint" serviceAddress="http://path.svc" doc:name="Web Service Consumer">
<ws:security>
<ws:wss-username-token username="uname" password="password" passwordType="TEXT" addCreated="true" addNonce="true"/>
<ws:wss-timestamp expires="60000"/>
</ws:security>
</ws:consumer-config>
<flow name="wsdltestFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<ws:consumer config-ref="Web_Service_Consumer" operation="PingWithAuthorization" doc:name="Web Service Consumer"/>
<logger level="INFO" doc:name="Logger" message="req gen : #[payload]"/>
</flow>
</mule>
I'm still not able to authenticate with any of the XMl

which datasource api supports both connection pooling and XA transactions?

In the below Mule flow, i have to implement both connection pooling and XA transaction for JDBC connectivity. which datasource API supports both connection pooling and XA distributed transaction and how to implement it using spring beans and configure it to jdbc component?
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:core="http://www.mulesoft.org/schema/mule/core"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:jbossts="http://www.mulesoft.org/schema/mule/jbossts" xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/jbossts http://www.mulesoft.org/schema/mule/jbossts/current/mule-jbossts.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<!-- <jdbc-ee:mysql-data-source name="MySQL_REP_Data_Source" user="${rep.db.user}"
password="${rep.db.password}" url="${rep.db.url}" transactionIsolation="UNSPECIFIED"
doc:name="MySQL Data Source" /> -->
<spring:beans>
<spring:bean id="MySQL_Data_Source"
class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"
name="Bean">
<spring:property name="driverClass" value="com.mysql.jdbc.Driver" />
<spring:property name="jdbcUrl" value="${rep.db.url}" />
<spring:property name="user" value="${rep.db.user}" />
<spring:property name="password" value="${rep.db.password}" />
<spring:property name="maxIdleTime" value="180" />
<spring:property name="minPoolSize" value="10" />
<spring:property name="acquireIncrement" value="-1" />
<spring:property name="maxPoolSize" value="100" />
</spring:bean>
</spring:beans>
<spring:beans>
<spring:bean id="MySQL_REP_Data_Source" name="MySQL_REP_Data_Source"
class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource">
<spring:property name="user" value="${rep.db.user}" />
<spring:property name="password" value="${rep.db.password}" />
<spring:property name="url" ref="${rep.db.url}" />
</spring:bean>
</spring:beans>
<jbossts:transaction-manager doc:name="Transaction Manager">
<property key="com.arjuna.ats.arjuna.coordinator.defaultTimeout"
value="${trans.default.timeout}" /> <!-- timeout in seconds -->
<property key="com.arjuna.ats.arjuna.coordinator.txReaperTimeout"
value="${trans.reaper.timeout}" /> <!-- timeout in milliseconds -->
</jbossts:transaction-manager>
<jdbc-ee:connector name="Reporting_Database"
dataSource-ref="MySQL_REP_Data_Source" validateConnections="true"
queryTimeout="-1" pollingFrequency="0" doc:name="Database">
<reconnect blocking="false" frequency="10000" count="3"></reconnect>
</jdbc-ee:connector>
<vm:connector name="VM_Connector" validateConnections="true"
doc:name="VM_Connector" createMultipleTransactedReceivers="true"
numberOfConcurrentTransactedReceivers="4">
</vm:connector>
<flow name="ApiKeyLoadImplFlow" doc:name="ApiKeyLoadImplFlow"
initialState="started">
<vm:inbound-endpoint exchange-pattern="request-response"
doc:name="Impl_ApiKeyLoad_Req" path="ImplApiKeyLoadReq"
connector-ref="VM_Connector" responseTimeout="${vm.response.timeout}">
<xa-transaction action="BEGIN_OR_JOIN" />
</vm:inbound-endpoint>
<logger message="Start of Api Key Load Implementation" level="DEBUG"
doc:name="ENTRY_LOG" />
<set-variable variableName="FlowData" value="#[payload]"
doc:name="FlowData" />
<set-variable variableName="#['UserId']" value="#[payload.getUserID()]"
doc:name="UserID" />
<choice doc:name="Choice">
<when expression="#[payload.getType().equalsIgnoreCase('incremental')]">
<choice doc:name="Choice">
<when expression="#[flowData.getAction().equalsIgnoreCase('update')]">
<flow-ref name="CheckApiKeyExistFlow" doc:name="CheckApiKeyExistsFlow" />
<choice doc:name="Choice">
<when expression="#[payload.size() == '0']">
<set-payload doc:name="FlowData" value="#[variable:FlowData]" />
<flow-ref name="InsertApiKeyFlow" doc:name="InsertApiKeyFlow" />
</when>
<when expression="#[payload.size() != '0']">
<set-payload doc:name="FlowData" value="#[variable:FlowData]" />
<flow-ref name="UpdateApiKeyFlow" doc:name="UpdateApiKeyFlow" />
</when>
<otherwise>
<set-payload value="#['Internal Server Error']"
doc:name="Internal_Server_Error" />
<logger message="Status for UserId #[flowVars.UserId] : #[payload]"
level="WARN" doc:name="Internal_Server_Status" />
</otherwise>
</choice>
</when>
<when expression="#[flowData.getAction().equalsIgnoreCase('delete')]">
<flow-ref name="CheckApiKeyExistFlow" doc:name="CheckApiKeyExistsFlow" />
<choice doc:name="Choice">
<when expression="#[payload.size() == '0']">
<set-payload value="#['DataNotFound']" doc:name="Data_Not_Found" />
<logger message="Status for UserId #[flowVars.UserId] : #[payload]"
level="WARN" doc:name="Data_Not_Found_Status" />
</when>
<when expression="#[payload.size() != '0']">
<set-payload doc:name="FlowData" value="#[variable:FlowData]" />
<flow-ref name="DeleteApiKeyFlow" doc:name="DeleteApiKeyFlow" />
</when>
<otherwise>
<set-payload value="#['Internal Server Error']"
doc:name="Internal_Server_Error" />
<logger message="Status for UserId #[flowVars.UserId] : #[payload]"
level="WARN" doc:name="Internal_Server_Status" />
</otherwise>
</choice>
</when>
<otherwise>
<set-payload value="#['InvalidAction']" doc:name="Invalid_Action" />
<logger message="Status for UserId #[flowVars.UserId] : #[payload]"
level="WARN" doc:name="Invalid_Action_Status" />
</otherwise>
</choice>
</when>
<when expression="#[payload.getType().equalsIgnoreCase('full')]">
<set-payload doc:name="FlowData" value="#[variable:FlowData]" />
<flow-ref name="InsertApiKeyFlow" doc:name="InsertApiKeyFlow" />
</when>
<otherwise>
<set-payload value="#['Internal Server Error']"
doc:name="Internal_Server_Error" />
<logger message="Status for UserId #[flowVars.UserId] : #[payload]"
level="WARN" doc:name="Internal_Server_Status" />
</otherwise>
</choice>
<logger message="End of Api Key Load Implementation" level="DEBUG"
doc:name="EXIT_LOG" />
<catch-exception-strategy doc:name="Catch Exception Strategy">
<logger level="WARN" doc:name="Exception_Log"
message="Exception in ApiKeyLoadImplFlow #[System.getProperty('line.separator')] Error Description = #[exception.getMessage()]" />
</catch-exception-strategy>
</flow>
<sub-flow name="CheckApiKeyExistFlow" doc:name="CheckApiKeyExistFlow">
<logger message="Start of Check Api Key Implementation" level="DEBUG"
doc:name="START_LOG" />
<jdbc-ee:outbound-endpoint exchange-pattern="request-response"
queryKey="checkdata" queryTimeout="-1" connector-ref="Reporting_Database"
doc:name="Check_Value_Exists">
<xa-transaction action="JOIN_IF_POSSIBLE" />
<jdbc-ee:query key="checkdata"
value="${ftp.db.t_bmrs_api_keys.checkdata.query}" />
</jdbc-ee:outbound-endpoint>
<logger message="End of Check Api Key Exists Implementation"
level="DEBUG" doc:name="EXIT_LOG" />
</sub-flow>
</mule>
You need to have a javax.sql.XADataSource that implements connection pooling. You will usually need a JDBC driver specific data source for this, because supporting XA (distributed transactions) requires close coordination with how the database system implements two-phase commit.
Note that contrary to what the name suggests, a javax.sql.ConnectionPoolDataSource should not provide connection pooling, it is a data source for a connection pool.

HTTP SOAP Post Request

I need to send HTTP Request to publish some data in a WS
E.g:
http://localhost:8081/hello/publishAMANSequence/filter/sequenceGenerationTime=1696-09-01T00:00:00Z&AMANId=B1&landingSequenceEntry=11234567890EST
I take this fault from server:
Parameter should be ordered in the following sequence: [sequenceGenerationTime, AMANId, landingSequenceEntry]
I'm doing something wrong in the order?
mule flow:
<jms:activemq-connector name="Active_MQ1" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
<flow name="jmsFlow1" doc:name="jmsFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="hello" doc:name="HTTP"/>
<cxf:jaxws-service doc:name="SOAP" serviceClass="aero.itec.amansequenceservice.AMANSequenceInfo"/>
<component doc:name="Java" class="implementations.AMANSequenceImpl"/>
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
<jms:outbound-endpoint queue="StudioIN" connector-ref="Active_MQ1" doc:name="JMS"/>
<logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
</flow>
The url which you have provided is wrong. There should be a questionmark(?) after "filter". Then only it will consider it as parameters
http://localhost:8081/hello/publishAMANSequence/filter?sequenceGenerationTime=1696-09-01T00:00:00Z&AMANId=B1&landingSequenceEntry=11234567890EST
Moreover if you are trying to access a webservice you can't do that with a HTTP GET. You need to send it as a SOAP request. You can use APIs like CXF, AXIS etc.
Following this tutorial ~
I create a flow for publish the WS , that have an inbound-endpoint where I do the request
publish.flow:
<jms:activemq-connector name="Active_MQ1" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
<flow name="jmsFlow1" doc:name="jmsFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="hello" doc:name="HTTP"/>
<cxf:jaxws-service doc:name="SOAP" serviceClass="aero.itec.amansequenceservice.AMANSequenceInfo" >
<cxf:jaxb-databinding/>
<cxf:inInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
</cxf:inInterceptors>
<cxf:outInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
</cxf:outInterceptors>
</cxf:jaxws-service>
<component doc:name="Java" class="implementations.AMANSequenceImpl"/>
<object-to-string-transformer doc:name="Object to String"/>
<jms:outbound-endpoint queue="StudioIN" connector-ref="Active_MQ1" doc:name="JMS"/>
<logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
</flow>
Then I create a client.class where I set the variable values:
client.java
public class AMANwsClient extends AbstractTransformer{
#Override
protected Object doTransform(Object src, String enc)
throws TransformerException {
AMANSequence sequence = new AMANSequence();
XMLGregorianCalendar fec;
sequence.setSequenceGenerationTime(fec);
sequence.setAMANId("AA");
System.out.println(sequence);
return sequence;
}
This class is used like a transformer, we don't need to pass parameters in the url, only need to connect to the endpoint URL
Finally, create a client.flow
<custom-transformer class="implementations.AMANwsClient" name="AMANwsClient" />
<flow name="csvPublisher">
<transformer ref="AMANwsClient" />
<object-to-string-transformer doc:name="Object to String"/>
<outbound-endpoint address="http://localhost:63081/hello" exchange-pattern="request-response">
<cxf:jaxws-client clientClass="aero.itec.amansequenceservice.AMANSequenceInfo_Service" port="AMANSequenceInfoService" operation="publishAMANSequence">
<cxf:inInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
</cxf:inInterceptors>
<cxf:outInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
</cxf:outInterceptors>
</cxf:jaxws-client>
</outbound-endpoint>
</flow>
Now I can save the payload into a JMS Queue and reproduce the payload from Browser, console and JMS.
If you have some suggestion to improve program performance, I'm open to listen to it.
Put http://localhost:8081/hello?wsdl in SOAPUI ... It will create the request and response there ... then you can pass the values in the request and invoke the webservice ...
Please check the following for your reference :-
http://developers-blog.org/blog/default/Webservice-testing-with-soapUI and http://quicksoftwaretesting.com/soapui-web-service-testing-tool/

How to make parallel outbound calls

My use case requires to enrich my input with smne data and send it to an outbound endpoint.
The data for enriching is obtained by making calls to two web-services and then extract the data from the reply.
This extracted data is enriched into my input XML and sent to an outbound endpoint.
The two web-service calls that I need to make needs to be parallel, as they don't have dependency on another. This way I could save my processing time.
Please suggest how I could achieve this parallel processing in a flow in Mule.
Note: I have tried using ALL flow control, but it seems that is calling the web-services (sub-flows) sequentially.
Given below is my abstract flow.
<flow name="mainFlow">
<inbound-endpoint> .....
<some validation>
<setting some flow variables>
<!-- Now make calls to the sub-flows which has some processing of the input and make some web-service calls -->
<all>
<flow-ref name="myFlow1" />
<flow-ref name="myFlow2" />
<flow-ref name="myFlow3" />
</all>
<enrich the input with the data obtained from the output of the above three flows>
<outbound-endpoint>
</flow>
<flow name="myFlow1">
<some transformer to transform the payload provided >
< the tran sformed payload is passed as input to the web-service call>
<http:outbound-endpoint ...>
<transform the reply from the web-service call>
</flow>
<flow name="myFlow2">
<some transformer to transform the payload provided >
< the tran sformed payload is passed as input to the web-service call>
<http:outbound-endpoint ...>
<transform the reply from the web-service call>
</flow>
<flow name="myFlow3">
<some transformer to transform the payload provided to it>
< the tran sformed payload is passed as input to the web-service call>
<http:outbound-endpoint ...>
<transform the reply from the web-service call>
</flow>
Here is a simple configuration that shows one way to make a fork/join with two HTTP outbound endpoints. To add a third endpoint, set MULE_CORRELATION_GROUP_SIZE to 3 and the MULE_CORRELATION_SEQUENCE of the third async flow-ref to 3.
<flow name="fork">
<vm:inbound-endpoint path="fork.in" />
<set-property propertyName="MULE_CORRELATION_GROUP_SIZE"
value="2" />
<all enableCorrelation="IF_NOT_SET">
<async>
<set-property propertyName="MULE_CORRELATION_SEQUENCE"
value="1" />
<flow-ref name="parallel1" />
</async>
<async>
<set-property propertyName="MULE_CORRELATION_SEQUENCE"
value="2" />
<flow-ref name="parallel2" />
</async>
</all>
</flow>
<sub-flow name="parallel1">
<logger level="INFO" message="parallel1: processing started" />
<http:outbound-endpoint address="..."
exchange-pattern="request-response" />
<logger level="INFO" message="parallel1: processing finished" />
<flow-ref name="join" />
</sub-flow>
<sub-flow name="parallel2">
<logger level="INFO" message="parallel2: processing started" />
<http:outbound-endpoint address="..."
exchange-pattern="request-response" />
<logger level="INFO" message="parallel2: processing finished" />
<flow-ref name="join" />
</sub-flow>
<sub-flow name="join">
<collection-aggregator timeout="6000"
failOnTimeout="true" />
<combine-collections-transformer />
<logger level="INFO"
message="Continuing processing of: #[message.payloadAs(java.lang.String)]" />
</sub-flow>
EDIT: In the above config, the aggregator times out after 6 seconds. This is potentially too short for your actual use case: increase as you see fit. Also it is set to fail on time-out, which is maybe not the behaviour you desire in case not all the outbound HTTP endpoint interactions succeeded: it's up to you to decide based on your use case.

Categories