2

We are using Spring Integration in our project and we have a requirement where If IBM MQ goes down then we will have to auto connect to IBM MQ when it is up. We have done this implementation using recoveryInterval option of org.springframework.jms.listener.DefaultMessageListenerContainer class. We have given recovery interval as 6 seconds so every 6 seconds system try to recover the MQ connection but now we have a requirement where we will have to do the autorecover twice only and after that if still MQ is down then stop the inbound adapter. Is there any way in Spring Integration to mention the auto recovery retry count so that system will try to recover only for that retry count?

Below is my existing configuration.

<bean id="inQ" class="com.ibm.mq.jms.MQQueue">
<constructor-arg value="${mq.inbound.queue}" />
</bean>
<int:channel id="inbound" />
<int-jms:message-driven-channel-adapter
    id="jmsIn" channel="inbound" container="messageListenerContainer"
    acknowledge="transacted" auto-startup="false">
</int-jms:message-driven-channel-adapter>

<int:service-activator id="mainService"
    input-channel="inbound" ref="messageListener" method="onMessage">
    <int:request-handler-advice-chain>
        <ref bean="retryWithBackoffAdviceSession" />
    </int:request-handler-advice-chain>
</int:service-activator>

<bean id="messageListenerContainer"
    class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="mqConnectionFactory" />
    <property name="destination" ref="inQ" />
    <property name="sessionTransacted" value="true" />
    <property name="maxConcurrentConsumers" value="${maxConcurrentConsumers}" />
    <property name="concurrentConsumers" value="${concurrentConsumers}" />
    <property name="receiveTimeout" value="${receiveTimeout}" />
    <property name="recoveryInterval" value="60000" />
    <property name="autoStartup" value="${autoStartup}" />
</bean>

Thanks Sach

sach
  • 127
  • 3
  • 13

1 Answers1

0

As an alternative to the recoveryInterval, you can now specify a Backoff instead (see the docs).

It doesn't provide a mechanism to stop the container but an appropriate backoff can effectively do what you want.

You would then need to programmatically stop/start to kick it off again.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179