On Thu, Nov 18, 2010 at 5:10 PM, Tim Chen <t...@evri.com> wrote: > Hi all, > > I wonder what's the best way to handle reconnect to the broker when broker > is unavailable (network is down / broker crashed, etc) using Java JMS > client > to C++ broker? >
Are you running a cluster or is it a bunch of standalone brokers ? > Currently when using the JMS client when the broker is killed, a runtime > exception ( ConnectionException ) is thrown internally in qpid and I don't > see a way I can get this exception. > > The Qpid JMS client supports transparent failover if configured properly. If you are running a cluster then ------------------------------------------- For c++ broker you can set the failover method to "failover_exchange" and the client will transparently retrieve the available brokers from the cluster and will connect to one of them if the current broker fails. Ex amqp://guest:gu...@clientid /testpath?brokerlist='tcp://localhost:5672'&failover='failover_exchange' If you are running a set of standalone brokers ------------------------------------------------------- You can set the failover method to round robin an provide a list of brokers. Ex amqp://guest:gu...@clientid /testpath?brokerlist='tcp://host1:5672;tcp://host2:5672..;tcp://hostn:5672'&failover='roundrobin' Also if all attempts are unsuccessful (i.e total cluster failure or all brokers in the list are down) then it will throw an exception if there is a connection listener set. It will not notify a connection exception If and only if it can connect to another broker in the cluster (or the list of brokers if provided with failover=roundrobin). i.e it will not notify any intermediate failures. > I tried to add a check each time it sends a message if the broker > connection > is closed ( AMQConnection.isClosed() ) to re-attempt to reconnect. > > However, I see that if the broker is disconnected not via > AMQConnection.close(), the state is never set to CLOSED and still set as > OPEN. > Please stick to the standard JMS interfaces as internal classes like AMQConnection are subject change from release to release. > > From reading this: > > http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.3/pdf/Programming_in_Apache_Qpid/Red_Hat_Enterprise_MRG-1.3-Programming_in_Apache_Qpid-en-US.pdf > > It has reconnect flags on using Python and C++ clients to automatically > reconnect if connection is lost. > > But I wonder what's the best way to do this in JMS client? > > Thanks, > > Tim > -- Regards, Rajith Attapattu Red Hat http://rajith.2rlabs.com/