[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Leaks in pinger when using manual reconnection?

jmesnil do-not-reply at jboss.com
Thu Aug 6 08:00:26 EDT 2009


== Setup ==

* 1 single server (no backup)
* JMS Connection Factory configured with:

  |    <retry-interval>1000</retry-interval> 
  |    <retry-interval-multiplier>1.0</retry-interval-multiplier> 
  |    <reconnect-attempts>-1</reconnect-attempts> 
  |    <failover-on-server-shutdown>true</failover-on-server-shutdown> 
  |    <call-timeout>5000</call-timeout>
  | 
With this configuration, clients will try to reconnect indefinitely on the single server.

* One JMS ExceptionListener for manual reconnection:


  | private ExceptionListener exceptionListener = new ExceptionListener()
  | {
  |    public void onException(JMSException arg0)
  |    {
  |       System.out.println("TopicExample.onException()");
  |       disconnect();
  |       reconnect();
  |    }
  | };
  | 

disconnect() closes the current JMS connection (if any)
reconnect() recreates all the JMS resources from JNDI

* The client registers a MessageListener (to print received messages) and send messages every 0.5s

I've added traces in the Pinger handlePacket() method to display when pings where received for which remoting connections.

== Steps ==

1. start the server

2. start the client

  => On the client, we create 2 remoting connections (1 when calling JMS cf.createConnection(), the other when calling JMS conn.createSession())
  => We receive pings for these 2 remoting connections
  
3. kills the server
  => On the client, the connection failure is detected:

  |   6 aout 2009 13:29:57 org.jboss.messaging.core.logging.Logger warn
  |   ATTENTION: Connection failure has been detected The connection was closed by the server:5
  |   6 aout 2009 13:29:57 org.jboss.messaging.core.logging.Logger warn
  |   ATTENTION: Connection failure has been detected The connection was closed by the server:5
  | 

4. Restart the server
  => On the client, we try to reattach the sessions to the servers. This code creates new RemotingConnections *and new Pingers*

  |   6 ao?t 2009 13:30:28 org.jboss.messaging.core.logging.Logger warn
  |   ATTENTION: 9342944 Session not found on server when attempting to re-attach
  |   6 ao?t 2009 13:30:28 org.jboss.messaging.core.logging.Logger warn
  |   ATTENTION: 11968595 Session not found on server when attempting to re-attach
  | 

5. Client's JMS ExceptionListener is called
  => when we try to close the current connection, it fails:

  |   javax.jms.JMSException: Timed out waiting for response when sending packet 74
  |    	at org.jboss.messaging.core.remoting.impl.ChannelImpl.sendBlocking(ChannelImpl.java:328)
  |    	at org.jboss.messaging.core.client.impl.ClientConsumerImpl.doCleanUp(ClientConsumerImpl.java:753)
  |    	at org.jboss.messaging.core.client.impl.ClientConsumerImpl.close(ClientConsumerImpl.java:318)
  |    	at org.jboss.messaging.jms.client.JBossMessageConsumer.close(JBossMessageConsumer.java:153)
  |    	at org.jboss.messaging.jms.client.JBossSession.close(JBossSession.java:275)
  |    	at org.jboss.messaging.jms.client.JBossConnection.close(JBossConnection.java:259)
  |    	at org.jboss.jms.example.TopicExample.disconnect(TopicExample.java:112)
  |    	at org.jboss.jms.example.TopicExample$2.onException(TopicExample.java:69)
  |    	at org.jboss.messaging.jms.client.JBossConnection$JMSFailureListener.connectionFailed(JBossConnection.java:545)
  |    	at org.jboss.messaging.core.remoting.impl.RemotingConnectionImpl.callFailureListeners(RemotingConnectionImpl.java:402)
  |    	at org.jboss.messaging.core.remoting.impl.RemotingConnectionImpl.fail(RemotingConnectionImpl.java:244)
  |    	at org.jboss.messaging.core.client.impl.ConnectionManagerImpl$Channel0Handler$1.run(ConnectionManagerImpl.java:1119)
  |    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
  |    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
  |    	at java.lang.Thread.run(Thread.java:613)
  |    Caused by: MessagingException[errorCode=3 message=Timed out waiting for response when sending packet 74]
  |    	... 15 more
  | 

5b. Still in the JMS ExceptionListener, we reconnect to the Server starting from JNDI resources. This creates new RemotingConnections *and new Pingers*

6. The client can once again produce and consume messages

*but* the client receives pings for 4 connections!
It receives pings for the 2 remoting connections which were created when reconnecting.
But it also receives pings for the 2 remoting connections which were created when reattaching the session at step #4.
The exception at step #5 prevented the JMS connection to be closed properly, including closing its associated remoting connection(s) and its pinger(s)

If I kill/restart the server once more, I have now 6 pingers on the client.


View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4248442#4248442

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4248442



More information about the jboss-dev-forums mailing list