如何使用CachingConnectionFactory设置重新连接值

时间:2015-10-13 01:41:31

标签: spring-integration spring-jms

在我的应用程序中,消息进入转矩,然后被发送到输出队列。我们通过spring集成来做到这一点。我的要求是,如果连接到输出队列时出现问题,那么它会尝试以30秒的延迟重新连接3次,最后如果失败则记录异常。你能帮忙解决一下这个问题吗?我的配置文件 -

jni/../../google_breakpad/../../src/client/linux/log/log.cc:47:7: error: expected nested-name-specifier before 'AndroidLogBufferWriteFunc'
 using AndroidLogBufferWriteFunc = int (*)(int bufID, int prio, const char *tag,
   ^
jni/../../google_breakpad/../../src/client/linux/log/log.cc:53:1: error: 'AndroidLogBufferWriteFunc' does not name a type
 AndroidLogBufferWriteFunc g_android_log_buf_write = nullptr;
 ^
jni/../../google_breakpad/../../src/client/linux/log/log.cc: In function 'void logger::initializeCrashLogWriter()':
jni/../../google_breakpad/../../src/client/linux/log/log.cc:60:3: error: 'g_android_log_buf_write' was not declared in this scope
   g_android_log_buf_write = reinterpret_cast<AndroidLogBufferWriteFunc>(
   ^
jni/../../google_breakpad/../../src/client/linux/log/log.cc:60:46: error: 'AndroidLogBufferWriteFunc' does not name a type
   g_android_log_buf_write = reinterpret_cast<AndroidLogBufferWriteFunc>(
                                          ^
jni/../../google_breakpad/../../src/client/linux/log/log.cc: In function 'int logger::writeToCrashLog(const char*)':
jni/../../google_breakpad/../../src/client/linux/log/log.cc:68:7: error: 'g_android_log_buf_write' was not declared in this scope
   if (g_android_log_buf_write) {

<bean id="mqQcfParent" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType">
<util:constant static-field="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP"/>
</property>
<property name="hostName" value="${mq.out.hostname}"/>
<property name="channel" value="${mq.out.channel}"/>
<property name="port" value="${mq.out.port}"/>
</bean>
<bean id="remoteConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="mqQcfParent"/>
<property name="sessionCacheSize" value="${mq.out.cacheSize}"/>
<property name="cacheProducers" value="true"/>
<property name="cacheConsumers" value="true"/>
</bean>
<bean id="inQueue" class="com.ibm.mq.jms.MQQueue">
<property name="baseQueueName" value="${mq.in.queue}"/>
</bean>
<bean id="aircraftAssignQueue" class="com.ibm.mq.jms.MQQueue">
<property name="baseQueueName" value="${mq.out.aircraftAssignQueue}"/>
</bean>
</bean>
<bean id="failureQueue" class="com.ibm.mq.jms.MQQueue">
<property name="baseQueueName" value="${mq.out.failureQueue}"/>
</bean>
<bean id="messageListenerContainerParent" class="org.springframework.jms.listener.DefaultMessageListenerContainer" abstract="true">
<property name="destination" ref="inQueue"/>
<property name="sessionTransacted" value="true"/>
<property name="maxConcurrentConsumers" value="${mq.in.max.consumer}"/>
<property name="concurrentConsumers" value="${mq.in.min.consumer}"/>
<property name="receiveTimeout" value="5000"/>
<property name="recoveryInterval" value="60000"/>
<property name="autoStartup" value="true"/>
</bean>
<bean id="messageListenerContainerCDC" parent="messageListenerContainerParent">
<property name="connectionFactory">
<bean parent="remoteConnectionFactory">
<property name="targetConnectionFactory">
<bean parent="mqQcfParent">
<property name="hostName" value="${mq.in.cdc.hostname}"/>
<property name="channel" value="${mq.in.cdc.channel}"/>
<property name="port" value="${mq.in.cdc.port}"/>
</bean>
</property>
</bean>
</property>
</bean>
<bean id="messageListenerContainerPDC" parent="messageListenerContainerParent">
<property name="connectionFactory">
<bean parent="remoteConnectionFactory">
<property name="targetConnectionFactory">
<bean parent="mqQcfParent">
<property name="hostName" value="${mq.in.pdc.hostname}"/>
<property name="channel" value="${mq.in.pdc.channel}"/>
<property name="port" value="${mq.in.pdc.port}"/>
</bean>
</property>
</bean>
</property>
</bean>
</beans>

1 个答案:

答案 0 :(得分:0)

您不会显示任何Spring Integration配置,但假设您使用的是JMS出站通道适配器,则可以添加retry advice并使用适当配置的SimplyRetryPolicy

但是,如果同一个代理也被用于入站队列,那么该会话将被破坏,并且无论如何都会重新传递消息;所以你可能最好在经纪人中设置重试策略。