Spring - JMS, after JMS server activemq start / stop pair, listener server throws java.io.EOFException and then doesn't connect to running JMS

I have the following setup in my spring context file.

<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, i.e. JMS activemq runs locally on the machine.

App Server listens for this activemq jms feature, when jms goes down, the following message is displayed on the app server, which is true as JMS is not actually working and it tries to check if it is not working every 5 seconds.

    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 JMS, the app server connects to it successfully and shows the following message.

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

      

Now when I uninstall the JMS server again, the appserver app shows the following message instead of showing the connection.

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 the JMS server the application server does not connect to it and continually throws java.io.EOFException

In what I noticed, before successfully reconnecting to JMS, part of the log message says: Reason. Consumer closed

where, as in other cases, he says Reason. The session is closed. and also the next line

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

      

+3


source to share


1 answer


The value for power.messagebrokerurl has been set to

power.messagebrokerurl=tcp://localhost:61616

      

If I add a failover at the beginning, I don't see this error.

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

      



Update: . With the above settings, the listener server always expected JMS to be up and running on startup. So I need to add the startupMaxReconnectAttempts attribute with values ​​as 1. By default, its value is -1 (I'm using ActiveMQ 5.5.0), which means that the transport will have no limit on the number of initial connection attempts and that the cause listener server hasn't started.

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

      

You can refer to http://activemq.apache.org/failover-transport-reference.html for all transport options.

0


source







All Articles