Search code examples
mulemule-studiomule-component

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.


Solution

  • 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>