Connection ClientId Identifier and AdvisoryMessage.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Connection ClientId Identifier and AdvisoryMessage.

Eric-AWL
Hi every body

I would want to be able to easily identify each of my TCP distant connection to my brokers without having to program anything on the client side.

I imagine using the jms.clientId on the client side with "tcp://myhost:xxxx?jms.clientID=myProject" as the connection URL, and catching AdvisoryMessage (ActiveMQ.Advisory.Connection) with another JMS "administrative" connection on the same broker. By this way, I hope that advisory messages received by my "administrative" connection, gives me the information that "myProject" justconnected or just disconnected.

I imagine that connectionInfo structure is the core message that is present on the topic at each connection, but the documentation (http://activemq.apache.org/advisory-message.html) doesn't mention it clearly.  

Is it a good and supported way to detect and identify connections ?

What would happen if 2 connections simultaneously use the same clientID ?

Thank you
Eric-AWL

Reply | Threaded
Open this post in threaded view
|

Re: Connection ClientId Identifier and AdvisoryMessage.

gtully
the jms clientId needs to be unique, only one connection with a given
id will be allowed.

you can define the prefix for a connection id via the clientIDPrefix
property. So tcp://xx:port?jms.clientIDPrefix="ID:<myHostName>myProject.".
The default value for the prefix is "ID:<hostName> so it would be good
to keep the host name.
This is combined with a seed such that it is unique.

Correct, the ConnectionInfo is in the body of the Connection advisory message.

On 23 March 2011 16:34, Eric-AWL <[hidden email]> wrote:

> Hi every body
>
> I would want to be able to easily identify each of my TCP distant connection
> to my brokers without having to program anything on the client side.
>
> I imagine using the jms.clientId on the client side with
> "tcp://myhost:xxxx?jms.clientID=myProject" as the connection URL, and
> catching AdvisoryMessage (ActiveMQ.Advisory.Connection) with another JMS
> "administrative" connection on the same broker. By this way, I hope that
> advisory messages received by my "administrative" connection, gives me the
> information that "myProject" justconnected or just disconnected.
>
> I imagine that connectionInfo structure is the core message that is present
> on the topic at each connection, but the documentation
> (http://activemq.apache.org/advisory-message.html) doesn't mention it
> clearly.
>
> Is it a good and supported way to detect and identify connections ?
>
> What would happen if 2 connections simultaneously use the same clientID ?
>
> Thank you
> Eric-AWL
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Connection-ClientId-Identifier-and-AdvisoryMessage-tp3399952p3399952.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



--
http://blog.garytully.com
http://fusesource.com
Reply | Threaded
Open this post in threaded view
|

Re: Connection ClientId Identifier and AdvisoryMessage.

Eric-AWL
Hi Gary

Thank you.

I will follow your advice.

I looked into IdGenerator.java source

I imagine that I should retreive "ID:<MyHostName>myProject.-one port number-timestamp-instanceCount:sequence"

Since "ConnectionInfo" usage is not documented at all on the website, can I use ConnectionInfo.getClientId() and analyze this answer to retreive "myProject" value, without being afraid that format changes and/or API won't be supported in near future versions ?

Eric-AWL

Reply | Threaded
Open this post in threaded view
|

Re: Connection ClientId Identifier and AdvisoryMessage.

gtully
You got to use ConnectionInfo.getConnectionId(), and your supplied
clientIDPrefix will be the start of the returned id.

fyi, the java doc from the website is a good reference:
http://activemq.apache.org/maven/5.4.0/activemq-core/apidocs/org/apache/activemq/command/ConnectionInfo.html

Maybe the simplest thing is to put a start/end marker, say '^' in the
clientIDPrefix that you can easily look for, just don't use ':' as
that is significant to the id parser.

On 24 March 2011 08:54, Eric-AWL <[hidden email]> wrote:

> Hi Gary
>
> Thank you.
>
> I will follow your advice.
>
> I looked into IdGenerator.java source
>
> I imagine that I should retreive "ID:myProject.-one port
> number-timestamp-instanceCount:sequence"
>
> Since "ConnectionInfo" usage is not documented at all on the website, can I
> use ConnectionInfo.getClientId() and analyze this answer to retreive
> "myProject" value, without being afraid that format changes and/or API won't
> be supported in near future versions ?
>
> Eric-AWL
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Connection-ClientId-Identifier-and-AdvisoryMessage-tp3399952p3401922.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



--
http://blog.garytully.com
http://fusesource.com