Return-Path: X-Original-To: apmail-qpid-users-archive@www.apache.org Delivered-To: apmail-qpid-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0740E90A2 for ; Tue, 29 May 2012 11:40:47 +0000 (UTC) Received: (qmail 91896 invoked by uid 500); 29 May 2012 11:40:46 -0000 Delivered-To: apmail-qpid-users-archive@qpid.apache.org Received: (qmail 91752 invoked by uid 500); 29 May 2012 11:40:46 -0000 Mailing-List: contact users-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@qpid.apache.org Delivered-To: mailing list users@qpid.apache.org Received: (qmail 91728 invoked by uid 99); 29 May 2012 11:40:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2012 11:40:46 +0000 X-ASF-Spam-Status: No, hits=3.1 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rajith77@gmail.com designates 74.125.82.170 as permitted sender) Received: from [74.125.82.170] (HELO mail-we0-f170.google.com) (74.125.82.170) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2012 11:40:40 +0000 Received: by werm13 with SMTP id m13so2633387wer.15 for ; Tue, 29 May 2012 04:40:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=L0Ly0V9/taIGpXly5hhB8faX8dsEUdm0bwpaB6eovdc=; b=QFD/kjYgD7PVvuIbpzzbH4Wl2nhQxRCrfmlGbMEtwwEzXwvs/6YtNe0xm7XqAU32Z5 BibNq7yjsYN4DmC+zJnCVbtsynMFEAofWGr1EkY68FNxpiPYlTMh34mkQ79bo/ClGK3N XVzgU6kx1jGInc5wqzUFOGn0utJd3Sf81Vtbf3esEgFD5kJIsCJA/25avuxIRa0otNmD FUzS78FkhO9iKSBvqIjR1kZ+HbzM7Sj0LCUDJ1Xuw/6sUSFB9q9gOTAnY2jdJe07jA1/ eeeHDjYKNSEMMz6jQ48fcdRExEsp9ZxS+Fn14jstSOWNfh9saxQovdk4K57uNrH3CZ9U jaIA== MIME-Version: 1.0 Received: by 10.216.139.19 with SMTP id b19mr7614736wej.4.1338291619269; Tue, 29 May 2012 04:40:19 -0700 (PDT) Received: by 10.216.193.130 with HTTP; Tue, 29 May 2012 04:40:19 -0700 (PDT) In-Reply-To: References: <1338200904371-7578072.post@n2.nabble.com> Date: Tue, 29 May 2012 07:40:19 -0400 Message-ID: Subject: Re: QPID (JMS) - What is the best way to check if the connection is still valid? From: Rajith Attapattu To: users@qpid.apache.org, keith.wall@gmail.com Content-Type: multipart/alternative; boundary=0016e6d467f0928b1204c12b4c9a X-Virus-Checked: Checked by ClamAV on apache.org --0016e6d467f0928b1204c12b4c9a Content-Type: text/plain; charset=ISO-8859-1 All though what Keith mentioned is a viable solution in the short term it may not be going forward as the new client that we are going to be build *may* not have these extensions in this exact form. A comparable solution may or may not be added. Therefore I would be a bit cautious when using anything that is not part of the official JMS interfaces. Otherwise you may find upgrading to a new release a bit cumbersome. Regards. Rajith On Tue, May 29, 2012 at 4:04 AM, Keith W wrote: > 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 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 > > 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 > > > > > > > > > --0016e6d467f0928b1204c12b4c9a--