You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Jaspreet Kaur <jk...@quark.com> on 2016/12/29 10:37:48 UTC

JMS client doesnot reconnect to broker 2 in case the topic subscriber did not consume any message so far.

Hi,
I am using ActiveMQ 5.14.1
I have a JMS consumer like....

ConnectionFactory connectionFactory = (ConnectionFactory) jndiLookup( 
                                        "ConnectionFactory", 
                                       
"org.apache.activemq.jndi.ActiveMQInitialContextFactory", 
                               
"failover:(discovery://(multicast://default?wireFormat.maxInactivityDuration=0&group=qpp))"); 
                        Connection connection =
connectionFactory.createConnection(); 
                        Session jmsSession = connection.createSession(false, 
                                        Session.AUTO_ACKNOWLEDGE); 
                        Topic topic = jmsSession.createTopic("t14"); 
                        MessageConsumer messageConsumer =
jmsSession.createConsumer(topic); 
                        messageConsumer.setMessageListener(new
QpsMessageListener()); 
                        connection.start(); 


I have observed that if no message is published to destination t14 and
broker B1 is killed. The above consumer exits.
But if i have a producer running, producing msgs continuously, then if I
kill broker B1, my subscriber automatically reconnects to B2. Why ?

Producer sample...

ConnectionFactory connectionFactory = (ConnectionFactory) jndiLookup(
					"ConnectionFactory",
					"org.apache.activemq.jndi.ActiveMQInitialContextFactory",
					 "failover:(discovery://(multicast://default?group=qpp))");
			Connection connection = connectionFactory.createConnection();
			connection.start();
			Session jmsSession =
connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
			Topic topic = jmsSession.createTopic("t14");
			MessageProducer messageProducer = jmsSession.createProducer(topic);
			int i =0 ;
			while(i < 3000){
				Thread.sleep(1000);
				i = i+1;
				javax.jms.TextMessage message = jmsSession.createTextMessage("test "+":
"+i);
				message.setStringProperty("OBJECT_TYPE", "ASSET");
				messageProducer.send(message);
			}
....
....

Thanks,
Jaspreet



--
View this message in context: http://activemq.2283324.n4.nabble.com/JMS-client-doesnot-reconnect-to-broker-2-in-case-the-topic-subscriber-did-not-consume-any-message-so-tp4720766.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: JMS client doesnot reconnect to broker 2 in case the topic subscriber did not consume any message so far.

Posted by Tim Bain <tb...@gmail.com>.
Exiting under those circumstances sounds like a bug.

Are there any relevant messages in the logs?

On Dec 29, 2016 3:54 AM, "Jaspreet Kaur" <jk...@quark.com> wrote:

> Hi,
> I am using ActiveMQ 5.14.1
> I have a JMS consumer like....
>
> ConnectionFactory connectionFactory = (ConnectionFactory) jndiLookup(
>                                         "ConnectionFactory",
>
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory",
>
> "failover:(discovery://(multicast://default?wireFormat.
> maxInactivityDuration=0&group=qpp))");
>                         Connection connection =
> connectionFactory.createConnection();
>                         Session jmsSession = connection.createSession(
> false,
>                                         Session.AUTO_ACKNOWLEDGE);
>                         Topic topic = jmsSession.createTopic("t14");
>                         MessageConsumer messageConsumer =
> jmsSession.createConsumer(topic);
>                         messageConsumer.setMessageListener(new
> QpsMessageListener());
>                         connection.start();
>
>
> I have observed that if no message is published to destination t14 and
> broker B1 is killed. The above consumer exits.
> But if i have a producer running, producing msgs continuously, then if I
> kill broker B1, my subscriber automatically reconnects to B2. Why ?
>
> Producer sample...
>
> ConnectionFactory connectionFactory = (ConnectionFactory) jndiLookup(
>                                         "ConnectionFactory",
>                                         "org.apache.activemq.jndi.
> ActiveMQInitialContextFactory",
>                                          "failover:(discovery://(
> multicast://default?group=qpp))");
>                         Connection connection = connectionFactory.
> createConnection();
>                         connection.start();
>                         Session jmsSession =
> connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
>                         Topic topic = jmsSession.createTopic("t14");
>                         MessageProducer messageProducer =
> jmsSession.createProducer(topic);
>                         int i =0 ;
>                         while(i < 3000){
>                                 Thread.sleep(1000);
>                                 i = i+1;
>                                 javax.jms.TextMessage message =
> jmsSession.createTextMessage("test "+":
> "+i);
>                                 message.setStringProperty("OBJECT_TYPE",
> "ASSET");
>                                 messageProducer.send(message);
>                         }
> ....
> ....
>
> Thanks,
> Jaspreet
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.
> nabble.com/JMS-client-doesnot-reconnect-to-broker-2-in-case-
> the-topic-subscriber-did-not-consume-any-message-so-tp4720766.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>