You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by philb1234 <ba...@gmail.com> on 2010/03/02 08:24:59 UTC

Detecting server shutdown - spring DefaultMessageListenerContainer

Hi,

We have registered a durable topic consumer using 
org.springframework.jms.listener.DefaultMessageListenerContainer.  When the
server is shut down or becomes unavailable we would like the consumer to be
notified in some way.  

Currently there is an exception logged in activemq on level debug but the
consumer is not aware that the server is no longer available.  Is it
possible to propogate this exception back through spring or register
somehwere in activeMQ to capture this 'server unavailable' event?

Client is linux activemq 5.2, spring 2.5.  Server is linux activemq 5.3

Here is the client log when the server is stopped.

2010-03-02 17:07:31,063 [taskExecutor-1] DEBUG 2010-03-02 17:07:32,063
[taskExecutor-1] DEBUG
org.springframework.jms.listener.DefaultMessageListenerContainer - Consumer
[ActiveMQMessageConsumer { value=ID:lab-1-33000-1267511832426-0:2:1:1,
started=true }] of session [PooledSession { ActiveMQSession
{id=ID:lab-1-33000-1267511832426-0:2:1,started=true} }] did not receive a
message
2010-03-02 17:07:32,704 [ActiveMQ Transport:
tcp://localhost/127.0.0.1:61616] DEBUG
org.apache.activemq.ActiveMQConnection - Async exception with no exception
listener: java.io.EOFException
java.io.EOFException
        at java.io.DataInputStream.readInt(DataInputStream.java:375)
        at
org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:269)
        at
org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:210)
        at
org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:202)
        at
org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:185)
        at java.lang.Thread.run(Thread.java:619)
2010-03-02 17:07:32,706 [ActiveMQ Connection Worker:
tcp://localhost/127.0.0.1:61616] DEBUG
org.apache.activemq.transport.tcp.TcpTransport - Stopping transport
tcp://localhost/127.0.0.1:61616
2010-03-02 17:07:33,063 [taskExecutor-1] DEBUG
org.springframework.jms.listener.DefaultMessageListenerContainer - Consumer
[ActiveMQMessageConsumer { value=ID:lab-1-33000-1267511832426-0:2:1:1,
started=true }] of session [PooledSession { ActiveMQSession
{id=ID:lab-1-33000-1267511832426-0:2:1,started=true} }] did not receive a
message
etc. . . 

Spring durable topic registration 
<jms:listener-container connection-factory="jmsFactory"
							task-executor="taskExecutor"
							acknowledge="transacted"
							destination-type="durableTopic"
							client-id="DLT">
		<jms:listener 	destination="logTopic" ref="listener"
subscription="durableLogTopic" />
</jms:listener-container>


Thanks

Cheers,

Phillip
-- 
View this message in context: http://old.nabble.com/Detecting-server-shutdown---spring-DefaultMessageListenerContainer-tp27752840p27752840.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Detecting server shutdown - spring DefaultMessageListenerContainer

Posted by Gary Tully <ga...@gmail.com>.
Don't think there is an easy way. You need to set a
ClientInternalExceptionListener on the underlying activemq connection, but
there is no easy way to set that via spring as there is no access to the
connection.

One option would be to provide your own connection factory that can wrap and
delegate to the acivemq connectionfactory and set a
clientInternalExceptionListener on each returned connection.
>From the implementation of the listener you can do what ever you need.

Shared instances of transport and exception listeners are already exposed on
the connection factory, I think it would make sense to also add a shared
clientInternalExceptionListener option also.

Could you open a jira issue to track this?


On 2 March 2010 07:24, philb1234 <ba...@gmail.com> wrote:

>
> Hi,
>
> We have registered a durable topic consumer using
> org.springframework.jms.listener.DefaultMessageListenerContainer.  When the
> server is shut down or becomes unavailable we would like the consumer to be
> notified in some way.
>
> Currently there is an exception logged in activemq on level debug but the
> consumer is not aware that the server is no longer available.  Is it
> possible to propogate this exception back through spring or register
> somehwere in activeMQ to capture this 'server unavailable' event?
>
> Client is linux activemq 5.2, spring 2.5.  Server is linux activemq 5.3
>
> Here is the client log when the server is stopped.
>
> 2010-03-02 17:07:31,063 [taskExecutor-1] DEBUG 2010-03-02 17:07:32,063
> [taskExecutor-1] DEBUG
> org.springframework.jms.listener.DefaultMessageListenerContainer - Consumer
> [ActiveMQMessageConsumer { value=ID:lab-1-33000-1267511832426-0:2:1:1,
> started=true }] of session [PooledSession { ActiveMQSession
> {id=ID:lab-1-33000-1267511832426-0:2:1,started=true} }] did not receive a
> message
> 2010-03-02 17:07:32,704 [ActiveMQ Transport:
> tcp://localhost/127.0.0.1:61616] DEBUG
> org.apache.activemq.ActiveMQConnection - Async exception with no exception
> listener: java.io.EOFException
> java.io.EOFException
>        at java.io.DataInputStream.readInt(DataInputStream.java:375)
>        at
>
> org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:269)
>        at
>
> org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:210)
>        at
> org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:202)
>        at
> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:185)
>        at java.lang.Thread.run(Thread.java:619)
> 2010-03-02 17:07:32,706 [ActiveMQ Connection Worker:
> tcp://localhost/127.0.0.1:61616] DEBUG
> org.apache.activemq.transport.tcp.TcpTransport - Stopping transport
> tcp://localhost/127.0.0.1:61616
> 2010-03-02 17:07:33,063 [taskExecutor-1] DEBUG
> org.springframework.jms.listener.DefaultMessageListenerContainer - Consumer
> [ActiveMQMessageConsumer { value=ID:lab-1-33000-1267511832426-0:2:1:1,
> started=true }] of session [PooledSession { ActiveMQSession
> {id=ID:lab-1-33000-1267511832426-0:2:1,started=true} }] did not receive a
> message
> etc. . .
>
> Spring durable topic registration
> <jms:listener-container connection-factory="jmsFactory"
>
>  task-executor="taskExecutor"
>
>  acknowledge="transacted"
>
>  destination-type="durableTopic"
>                                                        client-id="DLT">
>                <jms:listener   destination="logTopic" ref="listener"
> subscription="durableLogTopic" />
> </jms:listener-container>
>
>
> Thanks
>
> Cheers,
>
> Phillip
> --
> View this message in context:
> http://old.nabble.com/Detecting-server-shutdown---spring-DefaultMessageListenerContainer-tp27752840p27752840.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
http://blog.garytully.com

Open Source Integration
http://fusesource.com