You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by oagady <oa...@gmail.com> on 2011/07/27 23:49:22 UTC

Shutting down ActiveMQ kills topic subscriber client

I have a durable topic subscriber that I start the following way:

		TopicConnection topicConn = connectionFactory.createTopicConnection();
	        topicConn.setClientID("durable");

		TopicSession topicSession = topicConn.createTopicSession(false,
			           Session.AUTO_ACKNOWLEDGE);

		Topic topic = topicSession.createTopic(topicName);


		TopicSubscriber subscriber = topicSession.createDurableSubscriber(topic,
"MySubsriber");

		subscriber.setMessageListener(listener);
		topicConn.start();

If I shut down ActiveMQ broker when the client is running, this shuts down
the client as well. I don't see any exception thrown. 

Am I missing something with configuration? 

Thanks
Gali

--
View this message in context: http://activemq.2283324.n4.nabble.com/Shutting-down-ActiveMQ-kills-topic-subscriber-client-tp3699908p3699908.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Shutting down ActiveMQ kills topic subscriber client

Posted by oagady <oa...@gmail.com>.
The problem suddenly disapeared. I redesigned the consumer client, and moved
the code that initializes the connection, session and the listened in a
separate thread. The consumer doesn't crash any more - it survives the
broker reboot and reconnects to broker

Gali

--
View this message in context: http://activemq.2283324.n4.nabble.com/Shutting-down-ActiveMQ-kills-topic-subscriber-client-tp3699908p3705187.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Shutting down ActiveMQ kills topic subscriber client

Posted by oagady <oa...@gmail.com>.
Hi, Gary

Thanks for your reply. I ran examples, and both the producer and consumer
processes exited when I shut down ActiveMQ. The following is the exception
from the consumer console:

2011...' (length 1000)
     [java] [Thread-2] Received: 'Message: 924 sent at: Fri Jul 29 12:08:30
EDT
2011...' (length 1000)
     [java] [Thread-2] Received: 'Message: 925 sent at: Fri Jul 29 12:08:30
EDT
2011...' (length 1000)
     [java] [Thread-2] Received: 'Message: 926 sent at: Fri Jul 29 12:08:30
EDT
2011...' (length 1000)
     [java] [Thread-2] JMS Exception occured.  Shutting down client.
     [java] [Thread-2] Caught: javax.jms.JMSException: java.io.EOFException
     [java] javax.jms.JMSException: java.io.EOFException
     [java]     at
org.apache.activemq.util.JMSExceptionSupport.create(JMSExcept
ionSupport.java:62)
     [java]     at
org.apache.activemq.ActiveMQMessageConsumer.dequeue(ActiveMQM
essageConsumer.java:458)
     [java]     at
org.apache.activemq.ActiveMQMessageConsumer.receive(ActiveMQM
essageConsumer.java:577)
     [java]     at ConsumerTool.consumeMessagesAndClose(Unknown Source)
     [java]     at ConsumerTool.run(Unknown Source)
     [java] Caused by: java.io.EOFException
     [java]     at java.io.DataInputStream.readInt(DataInputStream.java:375)
     [java]     at
org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWir
eFormat.java:269)
     [java]     at
org.apache.activemq.transport.tcp.TcpTransport.readCommand(Tc
pTransport.java:227)
     [java]     at
org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTrans
port.java:219)
     [java]     at
org.apache.activemq.transport.tcp.TcpTransport.run(TcpTranspo
rt.java:202)
     [java]     at java.lang.Thread.run(Thread.java:662)
     [java] All threads completed their work

BUILD SUCCESSFUL
Total time: 34 seconds

C:\Tools\apache-activemq-5.5.0\example>


My problem is that I need consumer to run all the time, and survive the
ActiveMQ reboot.

I enabled debug statement for activemq libraries (on my own consumer), and
the last messages I see (after I shut down ActiveMQ, and my consumer exits)
is:

2011-07-28 17:04:52,062 | INFO  |
(org.apache.activemq.transport.failover.FailoverTransport:doReconnect:891)
Successfully connected to tcp://10.1.4.142:61616

2011-07-28 17:05:01,234 | DEBUG |
(org.apache.activemq.transport.tcp.TcpTransport:doStop:508)
Stopping transport tcp:///10.1.4.142:61616

2011-07-28 17:05:01,234 | WARN  |
(org.apache.activemq.transport.failover.FailoverTransport:handleTransportFailure:231)
Transport (/10.1.4.142:61616) failed to tcp://10.1.4.142:61616 , attempting
to automatically reconnect due to: java.io.EOFException

2011-07-28 17:05:01,234 | DEBUG |
(org.apache.activemq.transport.failover.FailoverTransport:handleTransportFailure:233)
Transport failed with the following exception:

java.io.EOFException
	at java.io.DataInputStream.readInt(Unknown Source)
	at
org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:269)
	at
org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:227)
	at
org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:219)
	at
org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:202)
	at java.lang.Thread.run(Unknown Source)
2011-07-28 17:05:01,234 | DEBUG |
(org.apache.activemq.transport.failover.FailoverTransport:getConnectList:683)
urlList connectionList:[tcp://10.1.4.142:61616], from:
[tcp://10.1.4.142:61616]

*2011-07-28 17:05:01,234 | DEBUG |
(org.apache.activemq.transport.failover.FailoverTransport:doReconnect:855)
Attempting connect to: tcp://10.1.4.142:61616*


I looked at the source code of ActiveMQ's *FailoverTransport.java* class
(*doReconnect* method), and I see that after that message I either should
see the exception caught by try/catch block (that connection failed), or a
message that connection was successful. So, I am supposed to get the
exception message since I shut down the broker, but I don't get it. Looks
like the JVM exists on the  spot somewhere between the lines:

SslContext.setCurrentSslContext(brokerSslContext);
t = TransportFactory.compositeConnect(uri);
t.setTransportListener(myTransportListener);
t.start();

if (started) {
    restoreTransport(t);
}


I am running ActiveMQ 5.5 on Java 1.6.0.24. May be I should try a different
JVM version

Gali


--
View this message in context: http://activemq.2283324.n4.nabble.com/Shutting-down-ActiveMQ-kills-topic-subscriber-client-tp3699908p3704587.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Shutting down ActiveMQ kills topic subscriber client

Posted by Gary Tully <ga...@gmail.com>.
not exactly sure what you are experiencing but maybe have a go at
reproducing with the examples
see: http://activemq.apache.org/examples.html

that may help clarify.

On 27 July 2011 22:49, oagady <oa...@gmail.com> wrote:
> I have a durable topic subscriber that I start the following way:
>
>                TopicConnection topicConn = connectionFactory.createTopicConnection();
>                topicConn.setClientID("durable");
>
>                TopicSession topicSession = topicConn.createTopicSession(false,
>                                   Session.AUTO_ACKNOWLEDGE);
>
>                Topic topic = topicSession.createTopic(topicName);
>
>
>                TopicSubscriber subscriber = topicSession.createDurableSubscriber(topic,
> "MySubsriber");
>
>                subscriber.setMessageListener(listener);
>                topicConn.start();
>
> If I shut down ActiveMQ broker when the client is running, this shuts down
> the client as well. I don't see any exception thrown.
>
> Am I missing something with configuration?
>
> Thanks
> Gali
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Shutting-down-ActiveMQ-kills-topic-subscriber-client-tp3699908p3699908.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
http://fusesource.com
http://blog.garytully.com