On 14 February 2017 at 18:14, pqvchen1 <vina.c...@gd-ms.com> wrote:
> I'm using qpid-jms-client-0.11.1.jar and try to figure out how to verify if a
> connection is ready for creating session. In initial I thought to check
> whether the connection is null or not and then realized that the connection
> object could be not null even it is not healthy to create a new connection.

You can call createSession as soon as you have a Connection object.
What happens at that point however depends how the client has been
configured and the Connection used before that point.

In the current 0.20.0 release, the client will perfom authentication
before returning the Connection object. If a ClientID is configured in
the URI, it will also establish the AMQP connection process before
returning the Connection object. Otherwise, it will wait for the
Connection to be used e.g by calling setClientID(), or calling
createSession. If you don't want it to wait and you don't want the
Connection to have a ClientID at all, you can set the
jms.awaitClientID option to false in the URI (see
http://qpid.apache.org/releases/qpid-jms-0.20.0/docs/index.html#jms-configuration-options)
so it will complete the AMQP connection process immediately as well.

In old 0.11.1 release, the client delayed both authenitcation and the
AMQP connection process until the Connection object was used if no
ClientID was configured in the URI, so to ensure the entire AMQP
connection process is complete before the Connection object is
returned from createConnection you would have to set a ClientID in the
URI.

> ( Actually, the ConnectionFactory.createConnection() throw an exception but
> the connection object is not null. So is there any way that I can check the
> healthy of a connection before creating a session..etc
>

It isnt possible for the createConnection method to throw an exception
and return a non-null Connection value at the same time.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org
For additional commands, e-mail: users-h...@qpid.apache.org

Reply via email to