I'm currently running a cluster, and I do see it is automatically failing
over to other nodes in the cluster.

But I am trying to test the case where all brokers in the cluster is down (
or in other words the cluster is down ),

I'm hoping both the producer and the client won't just die but keep on
attempting to reconnect until the cluster is backup, so I'm trying to

get the exception from the Javax.jms.connection so I can start the retry
logic.

You mentioned a connection listener, are you referring to ExceptionListener?


http://download.oracle.com/javaee/1.4/api/javax/jms/ExceptionListener.html

And also I wonder if there is any best practices for reconnecting when there
are multiple producers in different threads all sharing one connection but
multiple sessions?

Tim

On Mon, Nov 22, 2010 at 7:46 AM, Rajith Attapattu <rajit...@gmail.com>wrote:

> 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/
>

Reply via email to