You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Christopher Mihaly <cm...@hotmail.com> on 2006/07/19 01:48:48 UTC

Client already connected problem

I have a SOAP service, that when it is called, it creates a connection to the
message broker, and either retrieves messages froma durable topic or
publishes messages to that topic.   The SOAP service can be called pretty
quickly.   I have insured that the threads are synchronized and that it also
reuses active connections with the same clientid.    Howeever, it appears
that I get a already connected error still.  I am pretty sure that the web
service is synchroized, the debug statements appear to indicate that a
connection was established, the message sent, connection closed, and the
subsequent connection was establishe (which could be very quick after the
close) failes with the error.   Is it possible that there is some latency
between the time the connection is closed on the client and the connection
is actually closed on the server such that if a connection request on the
same client id happens too quickly, it wil fail?


-- 
View this message in context: http://www.nabble.com/Client-already-connected-problem-tf1963708.html#a5388581
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Client already connected problem

Posted by James Strachan <ja...@gmail.com>.
On 7/20/06, Christopher Mihaly <cm...@hotmail.com> wrote:
>
>  Ok, I agree I may not be using it the best way.   But, it doesn't seem
> correct to me that I can close a connection and then open a connection with
> the same name and have it fail.   If I close a connection, and the function
> returns successfully, I would think I should be able to turn around and open
> the connection again and have it succeed (assuming no other process comes in
> trying to open the connection with that ID, which it cannot in this
> scenario).  Why would this not be considered a bug?

Even though there is no reason at all to ever close a connection,
particularly as ActiveMQ supports auto-reconnection to deal with, we
should be able to handle code that does this.  So it does sound like a
bug to me - please raise an issue.

Just of interest, how long does it take to close the connection? In
previous versions of ActiveMQ we used to wait until a connection was
properly closed (blocking the client side until it was done). But
sometimes when folks were using embedded brokers or had transport
issues that could block the client unnecessarily causing shutdown to
hang. So we added a timeout now which defaults to 15 seconds.

I have an idea what the issue might be  - am about to raise a thread
on the dev list to investigate further
-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Client already connected problem

Posted by Christopher Mihaly <cm...@hotmail.com>.
 Ok, I agree I may not be using it the best way.   But, it doesn't seem
correct to me that I can close a connection and then open a connection with
the same name and have it fail.   If I close a connection, and the function
returns successfully, I would think I should be able to turn around and open
the connection again and have it succeed (assuming no other process comes in
trying to open the connection with that ID, which it cannot in this
scenario).  Why would this not be considered a bug?

   Thanks
      Chris


James.Strachan wrote:
> 
> On 7/19/06, Christopher Mihaly <cm...@hotmail.com> wrote:
>>
>> I have a SOAP service, that when it is called, it creates a connection to
>> the
>> message broker, and either retrieves messages froma durable topic or
>> publishes messages to that topic.   The SOAP service can be called pretty
>> quickly.   I have insured that the threads are synchronized and that it
>> also
>> reuses active connections with the same clientid.    Howeever, it appears
>> that I get a already connected error still.  I am pretty sure that the
>> web
>> service is synchroized, the debug statements appear to indicate that a
>> connection was established, the message sent, connection closed, and the
>> subsequent connection was establishe (which could be very quick after the
>> close) failes with the error.   Is it possible that there is some latency
>> between the time the connection is closed on the client and the
>> connection
>> is actually closed on the server such that if a connection request on the
>> same client id happens too quickly, it wil fail?
> 
> Yes, that sounds about right.
> 
> The idea behind JMS is that you create a connection up front and then
> reuse it over the duration of your application...
> 
> http://incubator.apache.org/activemq/how-do-i-use-jms-efficiently.html
> 
> so I'd recommend sharing the connection across requests. Note if you
> are just sending messages you can use the PooledConnectionFactory to
> do this for you if you don't want to change your code to avoid the
> create/close of JMS resources each time you have request to make
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 
-- 
View this message in context: http://www.nabble.com/Client-already-connected-problem-tf1963708.html#a5420724
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Client already connected problem

Posted by James Strachan <ja...@gmail.com>.
On 7/19/06, Christopher Mihaly <cm...@hotmail.com> wrote:
>
> I have a SOAP service, that when it is called, it creates a connection to the
> message broker, and either retrieves messages froma durable topic or
> publishes messages to that topic.   The SOAP service can be called pretty
> quickly.   I have insured that the threads are synchronized and that it also
> reuses active connections with the same clientid.    Howeever, it appears
> that I get a already connected error still.  I am pretty sure that the web
> service is synchroized, the debug statements appear to indicate that a
> connection was established, the message sent, connection closed, and the
> subsequent connection was establishe (which could be very quick after the
> close) failes with the error.   Is it possible that there is some latency
> between the time the connection is closed on the client and the connection
> is actually closed on the server such that if a connection request on the
> same client id happens too quickly, it wil fail?

Yes, that sounds about right.

The idea behind JMS is that you create a connection up front and then
reuse it over the duration of your application...

http://incubator.apache.org/activemq/how-do-i-use-jms-efficiently.html

so I'd recommend sharing the connection across requests. Note if you
are just sending messages you can use the PooledConnectionFactory to
do this for you if you don't want to change your code to avoid the
create/close of JMS resources each time you have request to make

-- 

James
-------
http://radio.weblogs.com/0112098/