I am trying to write a java application that can handle the rabbitmq server going down and coming back up (or losing the connection to the server and getting it back).<br><br>When my application is running and I stop the rabbitmq server, the ShutdownListener gets called (and some of the disconnection methods may throw some exceptions). So far all good.<br>
<br>When the server comes back up the application connects to the server: (It keeps trying to connect while the server is down until it successes.) <br><br>ConnectionFactory factory = new ConnectionFactory(params);<br>connection = factory.newConnection(host, AMQP.PROTOCOL.PORT);<br>
channel = connection.createChannel();<br>channel.accessRequest(this.realm);<br><br>Code above gets run through without any exceptions. But, when reconnecting, the execution stops at this line, the method seems to never return:<br>
<br>connection.addShutdownListener(shutdownListener);<br><br>At first time connection the same code is executed without any problems.<br><br>In some cases, when the connection is terminated from within my application, execution also stops at these lines:<br>
<br>channel.basicCancel(consumerTag);<br>channel.basicCancel(commandConsumerTag);<br><br>I have once seen addShutdownListener throw a ConcurrentModificationException, but the rabbitmq connection is not running in a multithreaded environment.<br>
<br>Is it possible to set a general timeout for all API method? Am I missing anything else wrt this problem? I understand that it may be impossible to find the cause of this with this little information unless anyone has seen anything similar. I am ready to supply more information that can help find the cause of this.<br>
<br>