现象
Active Mq 客户端连接Active Mq服务端时,如果因为服务器重启等原因导致Mq客户端无法发送Mq消息
原因
Mq客户端的连接和服务端已经断开,但是客户端没有进行重连
解决方法
Mq断开连接后,可以自动重连
main.properties
main.openmq.sName=330103000000800536
main.openmq.sPwd=123456
main.openmq.sIp=10.30.4.89
main.openmq.sPort=57666
spring+Active的配置:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="
com.dahuazwan.ihds.mq.productor
" />
<!-- enable transaction demarcation with annotations -->
<tx:annotation-driven />
<!-- OpenMq -->
<bean id = "connectionFactory" class = "org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://${main.openmq.sIp}:${main.openmq.sPort}" />
<property name="userName" value="${main.openmq.sName}" />
<property name="password" value="${main.openmq.sPwd}" />
</bean>
<!-- 采用TCP长连接方式, 避免每次建立短连接需要的额外工作时间 -->
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
<constructor-arg ref="connectionFactory"></constructor-arg>
</bean>
<!-- jms Template -->
<bean id="innerJmsTemplate"
class="org.springframework.jms.core.JmsTemplate" >
<property name="connectionFactory" >
<bean class="org.springframework.jms.connection.SingleConnectionFactory">
<property name="targetConnectionFactory" ref="pooledConnectionFactory" />
<property name="reconnectOnException" value="true"/>
</bean>
</property>
<property name="timeToLive" value="1000000"/>
<property name="receiveTimeout" value="222222" />
</bean>
<!-- Sms Destination -->
<bean id="smsDestination" class="org.apache.activemq.command.ActiveMQTopic">
<constructor-arg index="0" value="zw.public.all.sms"/>
</bean>
</beans>
里面的关键代码段是:
<property name="connectionFactory" >
<bean class="org.springframework.jms.connection.SingleConnectionFactory">
<property name="targetConnectionFactory" ref="pooledConnectionFactory" />
<property name="reconnectOnException" value="true"/>
</bean>
</property>
如果设置reconnectOnException=true,则Jms连接发生异常时,重新向服务端发起连接,默认是false
参考文献:
Spring JMS (3)
分享到:
相关推荐
关于Combining active learning and semi-supervised learning to construct SVM classifier的文章
active mq 实战教程,写的很不错,拿来分享
ActivePerl-----Openssl安装所需依赖,直接点击下一步安装,安装完一定要重启!!!重启!!!
ActivePerl-5.14.2-x86
包含两个示例中,第一个示例须要运行单独MQ(Apache Active MQ 5.15.0以下的版本)。第二个示例不需要运行单独的MQ。 有兴趣的朋友可以看看。两个示例运用的不同的方法去实现的。
QT开发必不可少,使用GRPC通讯测试时基本都必须的插件,WIN7-X64可用,最新perl,ActivePerl,win7x64可用的,grpc
开发active-mq的良好帮助指导手册
Jfinal -active mq: 消费:extends JFinalQueueConsumer 生产:JFinalQueue.sendMessage(queueName, message);
apache-activemq-5.11.1,是apache-MQ中间件压缩包,用于进行客户端与服务器之间的异步请求通讯,其中包含ActiveMQ(中文)参考手册
Active4j-flow是基于SpingBoot2.0与activiti7.x开发的一套工作流程管理系统。是以active4j-jsp为项目基础架构构建而成。以Spring Framework为核心容器,Spring MVC为模型视图控制器,Mybatis Plus为数据访问层, ...
Active_Directory--组策略之桌面管理.doc
Active MQ 与 WebSphere MQ 高可用性和管理分析。
spring boot +active mq 通过延时队列实现订单支付超时自动取消
apache-activemq-5.6.0 绿色版,解压即可启动
active_mq_mvc 源码,由一段if...else..判断引起的代码重构...,主要讲设计思想,以及设计模式,合理的运用反射,极度的省略了代码
Active Desktop Calendar是一个可完全定制的日期定制软件,提供日期记录,任务,闹钟以及联系方法等功能,并可与桌面背景进行无缝融合以及提供足够互动性。使用者 可将层中的数据进行有效组织,并在本地网络内进行...
Active MQ C++实现通讯 X86 librariy:CMS (stands for C++ Messaging Service)类似于JMS API用于同Message Brokers通讯(例如Active MQ)。 APR(Apache portable Run-time libraries,Apache可移植运行库)的目的如...
ActivePerl-5.28.1 win10 x64离线安装包(官方),可避免从官网下载速度慢的问题。 ActivePerl-5.28.1 win10 x64离线安装包(官方),可避免从官网下载速度慢的问题。 ActivePerl-5.28.1 win10 x64离线安装包(官方...
NoActive墓碑 v1.7-Alpha-Xposed模块.zip含下载地址可存云盘
Active MQ in Action,英文版。主要是ActiveMQ,manning