Mule - Stopping inbound endpoint until outbound endpoint connector is available - mule

I've given my mule config below and I use mule 3.4.0. When my activemq goes down the ftp endpoint reads the inbound files and tries to start the jms connector and I get the follwing error. JMS reconnect doesnt happen until I restart mule. Please help. Thanks
INFO 2013-10-09 13:14:53,925 [ActiveMQ Connection Executor: tcp://localhost/127.0.0.1:61616#43162] org.mule.exception.DefaultSystemExceptionStrategy: Exception caught is a ConnectException, attempting to reconnect...
INFO 2013-10-09 13:14:53,925 [ActiveMQ Connection Executor: tcp://localhost/127.0.0.1:61616#43162] org.mule.lifecycle.AbstractLifecycleManager: Stopping connector: ActiveMQJMSConnector
INFO 2013-10-09 13:14:53,948 [ActiveMQ Connection Executor: tcp://localhost/127.0.0.1:61616#43780] org.mule.exception.DefaultSystemExceptionStrategy: Exception caught is a ConnectException, attempting to reconnect...
ERROR 2013-10-09 13:14:53,949 [ActiveMQ Connection Executor: tcp://localhost/127.0.0.1:61616#43162] org.mule.exception.DefaultSystemExceptionStrategy: Failed to start Jms Connection
ERROR 2013-10-09 13:14:53,949 [ActiveMQ Connection Executor: tcp://localhost/127.0.0.1:61616#43780] org.mule.exception.DefaultSystemExceptionStrategy: Already in lifecycle phase 'stop', cannot fire the same phase twice
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:mule-xml="http://www.mulesoft.org/schema/mule/xml"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/3.4/mule-ftp.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.4/mule-file.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.4/mule-jms.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.4/mule.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/3.4/mule-xml.xsd">
<mule-xml:namespace-manager includeConfigNamespaces="true"/>
<ftp:endpoint name="FtpEndpointRecv" host="host1" path="/"
port="21" user="aaa" password="aaa"
pollingFrequency="600000" passive="true" >
</ftp:endpoint>
<jms:activemq-connector name="ActiveMQJMSConnector" specification="1.0.2b" brokerURL="tcp://localhost:61616">
<dispatcher-threading-profile maxThreadsActive="10" maxBufferSize="10" maxThreadsIdle="1" threadTTL="600000" poolExhaustedAction="WAIT" threadWaitTimeout="10000"/>
<reconnect-forever frequency="5000"/>
</jms:activemq-connector>
<file:file-to-string-transformer name="FileToStringTransformer"/>
<flow name="ftptojms">
<ftp:inbound-endpoint ref="FtpEndpointRecv" transformer-refs="FileToStringTransformer">
<file:filename-wildcard-filter pattern="*.xml"/>
</ftp:inbound-endpoint>
<all>
<logger level="INFO" message="#['Payload is:'+payload+'\nInbound Headers: '+message.inboundProperties.entrySet()+'\nOutbound Headers: '+message.outboundProperties.entrySet()+'\nExceptions: '+exception]"/>
<file:outbound-endpoint responseTimeout="10000" outputPattern="#[message.inboundProperties.originalFilename]" path="/test/msgcopy/"/>
<processor-chain>
<message-properties-transformer>
<add-message-property key="sourceFile" value="#[message.inboundProperties.originalFilename]"></add-message-property>
<add-message-property key="sourceDir" value="test"></add-message-property>
</message-properties-transformer>
<jms:outbound-endpoint queue="testQ" connector-ref="ActiveMQJMSConnector"></jms:outbound-endpoint>
</processor-chain>
</all>
</flow>
</mule>

Starting/stopping endpoints in case of errors, is not a typical pattern used in Mule.
Instead use a message processor like until-successful to keep retrying the jms:outbound-endpoint interaction until it succeeds.

Related

java.lang.OutOfMemoryError: GC overhead limit exceeded error while connection between mule and snowflake

I am creating a new flow in mule 3.9 using http connector and gerenic data base connector to connect to snowflake to run a procedure.
There are no error in the code,i could see that the codeis running successfully but i am getting
the below error.
java.lang.OutOfMemoryError: GC overhead limit exceeded
I have updated the anypoint.ini file upgraded the memory to 10240 still it didnt work
i am using snowflake jar 3.13.3 for this project
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cdata-snowflake="http://www.mulesoft.org/schema/mule/cdata-snowflake" 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/db http://www.mulesoft.org/schema/mule/db/current/mule-db.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/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/cdata-snowflake http://www.mulesoft.org/schema/mule/cdata-snowflake/current/mule-cdata-snowflake.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="testFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/test" allowedMethods="GET" doc:name="HTTP"/>
<db:stored-procedure config-ref="Generic_Database_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[call E2e_Change_User('nudayaku' ,'tan')]]></db:parameterized-query>
</db:stored-procedure>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
</mule>
i have tried but parameterized query as well as dynamic way , but both were resulting in timout error.
I have run the same procedure from snowflake , i am getting the output in seconds.
Can some help me how to fix the issue
Appreciate inputs
Thanks,
Sidh
This is a know issue in Mule 3.9.0 to Mule 3.9.4. The solution is to upgrade to Mule 3.9.5.
Source: https://help.mulesoft.com/s/article/Store-procedure-calls-fail-in-mule-3-x-for-snowflake-database

How to reconnect a JMS connector after a regular interval

Requirement :- A JMS Connector with a Oracle AQ as inbound endpoint.
Problem statement :- How to reconnect a JMS connector after a regular interval so that when it reconnect it consumes the new messages in queue.
I have tried the below reconnect strategy
-- JMS Connector defined
<jms:connector name="AQJMS" validateConnections="true"
maxRedelivery="-1" numberOfConsumers="1" durable="true" doc:name="JMS"
username="X" password="X" connectionFactory-ref="OAQTopicConnectionFactoryBean">
-- reconnect at 5 sec
<reconnect-forever frequency="5000"/>
</jms:connector>
-- flow
<flow name="sendmessagetoqFlow">
-- jms inbound endpoint as oracle AQ
<jms:inbound-endpoint queue="QUEUE"
connector-ref="AQJMS" doc:name="AQJMS">
<jms:client-ack-transaction action="BEGIN_OR_JOIN"/>
</jms:inbound-endpoint>
<logger message="Log 1 - #[message.inboundProperties]" level="INFO" doc:name="Logger 1"/>
</flow>
But its not reconnecting after 5 seconds.
Could you please help me solve the problem.
Thanks in Advance.
Configuring Transactional Polling (Enterprise)
This works for me
<jms:connector ...cut...>
<service-overrides transactedMessageReceiver="com.mulesoft.mule.transport.jms.TransactedPollingJmsMessageReceiver" />
</jms:connector>
<jms:inbound-endpoint queue="my.queue">
<ee:multi-transaction action="ALWAYS_BEGIN" timeout="30000"/>
<properties>
<spring:entry key="pollingFrequency" value="5000" />
</properties>
</jms:inbound-endpoint>

Quartz job to read wildcard filename only picks up one file

Using Mule 3.7. If I have 5 files in a directory with a .csv extension the below code only picks up one of the five files. If I remove the quartz trigger and make it a normal file:inbound-endpoint it picks up all five files. It seems so simple but does not work as intended.
Thanks,
-- Don
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:context="http://www.springframework.org/schema/context" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz"
xmlns:file="http://www.mulesoft.org/schema/mule/file" 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.6.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
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">
<file:connector name="fileInConnector" autoDelete="false" streaming="true" validateConnections="true" doc:name="FileConnector" />
<file:endpoint name="fileInEndpoint" path="\\\\c:\\scratch" connector-ref="fileInConnector" doc:name="FileEndpoint">
<file:filename-wildcard-filter pattern="*.csv" />
</file:endpoint>
<flow name="fileUploader">
<quartz:inbound-endpoint jobName="getFilesTrigger" cronExpression="/15 * * * * ?" doc:name="Quartz">
<quartz:endpoint-polling-job>
<quartz:job-endpoint ref="fileInEndpoint" />
</quartz:endpoint-polling-job>
</quartz:inbound-endpoint>
<logger message="Filename=#[message.inboundProperties.originalFilename]" level="INFO" doc:name="Logger" />
</flow>
</mule>
Here is the log after it firing twice:
INFO 2015-10-05 15:09:30,063 [scheduler-quartzcronfilepickup_Worker-1] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'fileInConnector.requester.2009817243'. Object is: FileMessageRequester
INFO 2015-10-05 15:09:30,069 [scheduler-quartzcronfilepickup_Worker-1] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'fileInConnector.requester.2009817243'. Object is: FileMessageRequester
INFO 2015-10-05 15:09:30,117 [[quartzcronfilepickup].fileUploader.stage1.02] org.mule.api.processor.LoggerMessageProcessor: Filename=D1.csv
INFO 2015-10-05 15:09:45,015 [scheduler-quartzcronfilepickup_Worker-2] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'fileInConnector.requester.636902426'. Object is: FileMessageRequester
INFO 2015-10-05 15:09:45,016 [scheduler-quartzcronfilepickup_Worker-2] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'fileInConnector.requester.636902426'. Object is: FileMessageRequester
INFO 2015-10-05 15:09:45,022 [[quartzcronfilepickup].fileUploader.stage1.02] org.mule.api.processor.LoggerMessageProcessor: Filename=D1.csv
There is a major difference between using a polling file inbound-endpoint and a Quartz inbound-endpoint polling a file endpoint: the former uses a message receiver, while the latter uses a message requester. Being two different beasts, they have the potential to be implemented quite differently.
And, guess what?, that's exactly the case for files. The file message receiver uses a lock mechanism to prevent polling a file that is being processed, while the requester does not.
The fun bit is this comment in the source code of the requester:
// Don't we need to try to obtain a file lock as we do with receiver
This doubt and the lack of lock usage in the requester is what makes it behave differently than the receiver. The fact this has never been solved for sure probably means that adding a lock there has undesired side-effects.
In any case, if you persist in using Quartz, I suggest you move the file being processed to another directory to prevent having it re-polled. The file endpoint should be able to do the move for you.

amqp ssl connection error

Hi I am trying to create a very simple AMQP connector to talk to my localhost RabbitMQ server using SSL. Without SSL, the connection works fine but I suspect my SSL configuration is incorrect. Can anyone shed light on this? I'm quite a newbie to Mule so apologies if this is ridiculous.
</ssl:connector>
<flow name="here_we_go_againFlow1">
<amqp:inbound-endpoint exchangeName="sales_exchange" queueName="sales_queue" responseTimeout="10000" exchange-pattern="request-response" connector-ref="AMQP_0_9_Connector" doc:name="AMQP-0-9" ref="AMQP_0_9"/>
<ssl:outbound-endpoint host="localhost" port="5671" responseTimeout="10000" doc:name="SSL (TLS)"/>
<echo-component doc:name="Echo"/>
</flow>
I assume you are trying to connect to an AMQP server over SSL. Here is an example using the ampqs transport. Note the namespaces etc.
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:amqps="http://www.mulesoft.org/schema/mule/amqps" xmlns:spring="http://www.springframework.org/schema/beans"
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/amqps http://www.mulesoft.org/schema/mule/amqps/current/mule-amqps.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<amqps:connector name="amqpsDefaultSslConnector" />
<flow name="amqp">
<amqps:inbound-endpoint exchangeName="target-exchange"
exchangeType="fanout" exchangeDurable="true" exchangeAutoDelete="false"
queueName="target-queue" queueDurable="true" queueAutoDelete="false"
queueExclusive="true" routingKey="a.b.c" connector-ref="amqpsDefaultSslConnector" />
....
</flow>
</mule>
There's also more advanced configuration such as setting up key stores etc. Examples can be found here: https://github.com/mulesoft/mule-transport-amqp/blob/master/mule-transport-amqp/src/test/resources/amqps-namespace-config.xml

Making WebMQ Synchronous

I'm trying to make WebMQ act synchronously in MULE in order to turn the message queue into a REST api for an internal project. Unfortunately, I know very little about MULE.
After a good bit of work, I started understanding the Request-Reply scope and tried to use the WMQ Connector with it, only to find out that WMQ only sends once the flow has ended.
I've tried putting the request into a different flow using VM to trigger it
but so far that just leads to it waiting forever on WMQ that will never happen.
I've also tried using VMs for back and forth:
But it seems to do the same thing as without, where it just ignores the input.
Now I know the input and output for the WMQ are working, as I previously setup a flow that used http to communicate with itself and let it know when a message went through.
What I essentially want is this, but using HTTP instead of AJAX
My latest, and perhaps closest attempt looks like thus:
The XML being:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" version="EE-3.6.0" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:ajax="http://www.mulesoft.org/schema/mule/ajax" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio" xmlns:test="http://www.mulesoft.org/schema/mule/test" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ajax http://www.mulesoft.org/schema/mule/ajax/current/mule-ajax.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd
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/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd
http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/current/mule-test.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd">
<wmq:connector channel="MAGENTO.SVRCONN" doc:name="WMQ Connector" hostName="[ip]" name="wmqConnector" port="1414" queueManager="MAGENTO" transportType="CLIENT_MQ_TCPIP" validateConnections="true" />
<vm:connector name="VM" validateConnections="true" doc:name="VM">
<vm:queue-profile maxOutstandingMessages="500">
<default-persistent-queue-store/>
</vm:queue-profile>
</vm:connector>
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="Input">
<http:listener config-ref="HTTP_Listener_Configuration" path="/mq" doc:name="HTTP"/>
<set-payload value="#[message.inboundProperties.'http.query.params'.xml]" doc:name="Set Payload"/>
<logger message="Entering Request-Reply Payload: #[payload]" level="INFO" doc:name="Logger"/>
<request-reply doc:name="Request-Reply">
<vm:outbound-endpoint exchange-pattern="one-way" path="mq" connector-ref="VM" doc:name="VM_TriggerSend" />
<vm:inbound-endpoint exchange-pattern="request-response" path="mq-return" connector-ref="VM" doc:name="VM_Receive" />
</request-reply>
<logger message="Request-Reply has ended. Payload: #[payload]" level="INFO" doc:name="Logger"/>
</flow>
<flow name="Send_Message">
<vm:inbound-endpoint exchange-pattern="one-way" path="mq" connector-ref="VM" doc:name="VM_Send"/>
<logger message="(Preparing to Dispatch) Payload: #[payload]" level="INFO" doc:name="Logger"/>
<wmq:outbound-endpoint queue="PUT_QUEUE" connector-ref="wmqConnector" doc:name="WMQ"/>
<logger message="Message presumably being dispatched after this log" level="INFO" doc:name="Logger"/>
</flow>
<flow name="Receive_Message">
<wmq:inbound-endpoint queue="GET_QUEUE" connector-ref="wmqConnector" doc:name="WMQ_Receive" />
<logger message="Triggering Receive" level="INFO" doc:name="Logger"/>
<vm:outbound-endpoint exchange-pattern="request-response" path="mq-return" connector-ref="VM" doc:name="VM_TriggerReceive" />
</flow>
</mule>
Which almost works, but it hangs indefinitely without sending a response back to the HTTP server. Setting the vm:inbound-endpoint in the Request-Reply flow to one-way keeps it from hanging, but doesn't send the new payload that's been received, but instead the previous payload (as if it's being skipped over).
Any help at all would be greatly appreciated!
If I understood correctly you are just trying to expose a request on a queue and a response on a well known queue as a REST api.
There is no need of VM queues there, and neither request-reply elements as the JMS transport can simulate the request response exchange pattern.
JMS queues are just one way. You have to necesarily reply on a different queue. The logic behind a request-response scenario is an outbound-endpoint that having an outbound property: MULE_REPLYTO. This property should be set with the name of your well known reply to queue: GET_QUEUE (if no such header is provided a temporary queue will be created).
The MULE_REPLY to header will become the standard JMSReplyTo when the mesasge is received at the service. The service has to honor this header sending the reply back to that queue. If the service is implemented on Mule this will happen automatically, otherwise it might not happen. You should double check its being honored.
If you want to use a request-reply scope with to one-way endpoints rather than one request-reponse endpoint, it is fine, should work the same but with more code.
Making an Asynchronous datasource Synchronous can indeed be tricky. But I don't really see an issue with your request-reply strategy.
Try to use an request-reply with WMQ endpoint on both sides. Then monitor the queues and see that the message and reply arrives as they should. Do you use the same queue for the request and the reply? The simplest scenario would be to use different ones, is that possible for your use-case?