qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keith W <keith.w...@gmail.com>
Subject Re: QPID (JMS) - What is the best way to check if the connection is still valid?
Date Tue, 29 May 2012 08:04:22 GMT
Hello Hamid

In addition to what Rajith has said already, you may also may want to look
at the ConnectionListener.

ConnectionListener#preFailover() is fired immediately before the client
begins the attempt to re-estabish a connection.  Once the client has
reestablished the connection, it will fire
ConnectionListener#failoverComplete.  You might consider using this
listener to _trigger_ the logging you desire.

The ConnectionListener interface is a Qpid specific extension to the JMS
API, but is part of the Qpid public API.  To set the ConnectionListener,
you need to cast the JMS Connection object back to its AMQConnection and
call setConnectionListener, passing your implementation of the
ConnectionListener interface.

AMQConnection#setConnectionListener(org.apache.qpid.jms.ConnectionListener);

Hope this helps

Keith,.



On 28 May 2012 18:34, Rajith Attapattu <rajith77@gmail.com> wrote:

> Hamid,
>
> At the moment JMS provides transparent failover. Therefore you will only
> get notified (via the exception listener) if you cannot reconnect
> successfully.
> Since these reconnects are transparent to the application, I wonder why you
> want to log them?
>
> If you really want to go that route, you could turn off transparent
> failover using failover='nofailover' in the connection URL.
> This will allow you to reconnect manually instead of letting the client do
> it and you could easily do you logging.
>
> Another potential option is to look at what QMF might offer.
> QMF (the management framework) *may* provide events if a connection is lost
> under certain circumstances.
> Ex. network issue.  However it will not provide events if the broker being
> connected to dies.
>
> Hope this helps.
>
> Rajith
>
> On Mon, May 28, 2012 at 6:28 AM, Hamid.Shahid <hamid2418@hotmail.com>
> wrote:
>
> > Hi,
> >
> > I am using Qpid in a java application (JMS). I am creating a connection
> > object to connect with the borker and to read messages from the queue, I
> am
> > using MessageListener. Everything is working fine. When I lose the
> > connection with the broker, the qpid logs the exceptions and tries to
> > reconnect with broker again until it connects and everything starts to
> work
> > fine again.
> >
> > But, I want to log some extra logging from a seprate thread while qpid is
> > trying to reconnect and somehow the connection object never get null and
> > the
> > qpid exceptions are not breaking the thread. So, is there a way I can
> check
> > the current status of the connection?
> >
> > The only way I found is the try to create a new temp session in the
> thread
> > and if it fails I do the logging and if it does not I close the temp
> > session. But I think it is not the best way, since it will create a temp
> > session in the thread every 30sec.
> >
> > Please let me know, how can I get the connection status.
> >
> > Thank you.
> >
> > - Hamid.
> >
> > --
> > View this message in context:
> >
> http://qpid.2158936.n2.nabble.com/QPID-JMS-What-is-the-best-way-to-check-if-the-connection-is-still-valid-tp7578072.html
> > Sent from the Apache Qpid users mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> > For additional commands, e-mail: users-help@qpid.apache.org
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message