1、activemq的重连机制

maxReconnectAttempts

-1 | 0

From version 5.6 onwards: -1 is default and means retry forever, 0 means don't retry (only try connection once but no retry).
Prior to version 5.6: 0 is default and means retry forever.
All versions: If set to >0, then this is the maximum number of reconnect attempts before an error is sent back to the client.

版本不一样,设置重连的值也不一样,5.6之前的是0代表无限重连,5.6之前的是-1代表重连

http://activemq.apache.org/failover-transport-reference.html

2、activemq的配置host出现问题

在linux的/etc/hosts/目录下添加配置信息

[2015-10-21 18:17:43][WARN ][org.apache.activemq.util.IdGenerator:58] could not generate unique stub
java.net.UnknownHostException: portal.test: portal.test: Name or service not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1438) ~[na:1.7.0_09-icedtea]
at org.apache.activemq.util.IdGenerator.<clinit>(IdGenerator.java:52) ~[activemq-all-activemq-all-5.3.2.jar:5.3.2]
at org.apache.activemq.ActiveMQConnection.<clinit>(ActiveMQConnection.java:110) [activemq-all-activemq-all-5.3.2.jar:5.3.2]
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:291) [activemq-all-activemq-all-5.3.2.jar:5.3.2]
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:259) [activemq-all-activemq-all-5.3.2.jar:5.3.2]
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:230) [activemq-all-activemq-all-5.3.2.jar:5.3.2]
at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:178) [activemq-all-activemq-all-5.3.2.jar:5.3.2]
at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:125) [activemq-pool-5.3.2.jar:5.3.2]
at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:110) [activemq-pool-5.3.2.jar:5.3.2]
at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:81) [activemq-pool-5.3.2.jar:5.3.2]
at org.springframework.jms.connection.SingleConnectionFactory.doCreateConnection(SingleConnectionFactory.java:342) [spring-jms-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.jms.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:288) [spring-jms-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.jms.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:225) [spring-jms-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184) [spring-jms-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:405) [spring-jms-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:373) [spring-jms-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer.establishSharedConnection(DefaultMessageListenerContainer.java:765) [spring-jms-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.jms.listener.AbstractJmsListeningContainer.doStart(AbstractJmsListeningContainer.java:280) [spring-jms-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.jms.listener.AbstractJmsListeningContainer.start(AbstractJmsListeningContainer.java:265) [spring-jms-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer.start(DefaultMessageListenerContainer.java:566) [spring-jms-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:167) [spring-context-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51) [spring-context-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:339) [spring-context-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:143) [spring-context-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:108) [spring-context-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:945) [spring-context-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) [spring-context-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410) [spring-web-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779) [catalina.jar:7.0.26]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273) [catalina.jar:7.0.26]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.26]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895) [catalina.jar:7.0.26]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871) [catalina.jar:7.0.26]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615) [catalina.jar:7.0.26]
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958) [catalina.jar:7.0.26]
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599) [catalina.jar:7.0.26]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_09-icedtea]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [na:1.7.0_09-icedtea]
at java.util.concurrent.FutureTask.run(FutureTask.java:166) [na:1.7.0_09-icedtea]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_09-icedtea]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_09-icedtea]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_09-icedtea]
Caused by: java.net.UnknownHostException: portal.test: Name or service not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.7.0_09-icedtea]
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:866) ~[na:1.7.0_09-icedtea]
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1258) ~[na:1.7.0_09-icedtea]
at java.net.InetAddress.getLocalHost(InetAddress.java:1434) ~[na:1.7.0_09-icedtea]
... 43 common frames omitted
[2015-10-21 18:17:43][INFO ][org.springframework.jms.connection.CachingConnectionFactory:291] Established shared JMS Connection: PooledConnection { org.apache.activemq.pool.ConnectionPool@64055601 }
05-11 11:18