简体   繁体   English

Spring - JMS,在JMS activemq服务器启动/停止几次后,侦听器服务器抛出java.io.EOFException,然后不连接到运行JMS

[英]Spring - JMS , after couple of start/stop of JMS activemq server, listener server throws java.io.EOFException and then does not connect to running JMS

I have following setting in my spring context file. 我在我的spring上下文文件中有以下设置。

<bean id="amqPowerConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <constructor-arg index="0" value="${power.messagebrokerurl}"/>
</bean>

<bean id="powerConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
    <constructor-arg ref="amqPowerConnectionFactory"/>
</bean>

<bean id="powerEventQueue" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg value="PowerEventQueue"/>
</bean>

<bean id="timeSeriesChangesContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="powerConnectionFactory"/>
    <property name="destination" ref="powerEventQueue"/>
    <property name="messageListener" ref="timeSeriesDataAdapter"/>
    <property name="recoveryInterval" value="5000"/>
</bean>

<bean id="timeSeriesDataAdapter" class="com.sungard.energy.aligne.aligneweb.assetManagement.TimeSeriesMessageAdapter">
    <property name="queueName"><value>"PowerEventQueue"</value></property>
    <property name="messageHandler"  ref="timeSeriesMessageHandler"/>
</bean>

<bean id="timeSeriesMessageHandler" class="com.sungard.energy.aligne.aligneweb.assetManagement.TimeSeriesMessageHandler">
</bean>

"${power.messagebrokerurl}" is tcp://localhost:61616 ie JMS activemq running locally on machine. “$ {power.messagebrokerurl}”是tcp:// localhost:61616,即在机器上本地运行的JMS activemq。

App Server is listening to this activemq jms, when jms goes down , app server shows following message, which is right since JMS is actually down and it's trying to see if it's up or not at every 5 seconds. App Server正在监听这个activemq jms,当jms关闭时,app server显示以下消息,这是正确的,因为JMS实际上是关闭的,并且它试图查看它是否每5秒启动一次。

    WARN DefaultMessageListenerContainer:844 - Setup of JMS message listener invoker failed for destination 'queue://PowerEventQueue' - trying to recover. Cause: The *Consumer* is closed
Could not refresh JMS Connection for destination 'queue://PowerEventQueue' - retrying in 5000 ms. Cause: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connect

Now when I restart my JMS, app server successfully connects to it and shows following message. 现在,当我重新启动JMS时,应用服务器成功连接到它并显示以下消息。

INFO DefaultMessageListenerContainer:893 - Successfully refreshed JMS Connection
WARN CachingConnectionFactory:301 - Encountered a JMSException - resetting the underlying JMS Connection

Now when i take down JMS server again appserver instead of showing connection refused shows following message. 现在当我再次关闭JMS服务器appserver而不是显示连接拒绝显示以下消息。

WARN DefaultMessageListenerContainer:844 - Setup of JMS message listener invoker failed for destination 'queue://PowerEventQueue' - trying to recover. Cause: The Session is closed
INFO CachingConnectionFactory:291 - Established shared JMS Connection: ActiveMQConnection {id=ID:ap-pun-ws0430-53381-1437557704588-0:28,clientId=null,started=false}
ERROR DefaultMessageListenerContainer:909 - Could not refresh JMS Connection for destination 'queue://PowerEventQueue' - retrying in 1000 ms. Cause: The JMS connection has failed: java.io.EOFException

and now even if I start JMS server, appserver does not reconnect to it and continuously throws java.io.EOFException 现在即使我启动JMS服务器,appserver也不会重新连接它并不断抛出java.io.EOFException

On thing I observed is that at before successful reconnection to JMS, part of log message says , Cause: The Consumer is closed 我观察到的事情是,在成功重新连接到JMS之前,部分日志消息显示,原因: 消费者已关闭

where-as in other case it says Cause: The Session is closed and also following line 在哪里 - 如在其他情况下,它说原因: 会话已关闭,也跟随线

INFO CachingConnectionFactory:291 - Established shared JMS Connection: ActiveMQConnection {id=ID:ap-pun-ws0430-53381-1437557704588-0:28,clientId=null,started=false}

Value for power.messagebrokerurl was set to power.messagebrokerurl的价值被设定为

power.messagebrokerurl=tcp://localhost:61616

If I add failover in the beginning of it, I don' see this error. 如果我在开头添加故障转移,我就不会看到此错误。

power.messagebrokerurl=failover:tcp://localhost:61616

Update: With above settings, listener server always expected JMS to be up and running when it starts. 更新:通过上述设置,侦听器服务器始终期望JMS在启动时启动并运行。 So I have to add startupMaxReconnectAttempts attribute with values as 1. By default its value is -1 (I am using ActiveMQ 5.5.0) which signifies that the transport will have no limit to the number of initial connection attempts and that's the reason listener server was not starting. 所以我必须添加startupMaxReconnectAttempts属性,其值为1.默认情况下,它的值为-1(我使用的是ActiveMQ 5.5.0),这表示传输对初始连接尝试次数没有限制,这就是监听服务器的原因没有开始。

power.messagebrokerurl=failover:(tcp://localhost:61616)?startupMaxReconnectAttempts=1

You can refer to http://activemq.apache.org/failover-transport-reference.html for all the transport options. 您可以参考http://activemq.apache.org/failover-transport-reference.html获取所有传输选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM