[rabbitmq-discuss] AlreadyClosedException in Java client

jiri at krutil.com jiri at krutil.com
Wed Nov 3 10:08:20 GMT 2010


Our Java client sometimes (randomly) can't publish a message:  
AlreadyClosedException: clean connection shutdown; reason: Attempt to  
use closed channel

The client uses a single connection and multiple channels across  
multiple threads.

I'm seeing this error in a method, which creates a channel, publishes  
a single message using basicPublish and closes the channel. It seems  
that the problem occurs when the method is being invoked in a loop  
from two threads at the same time. The channel is a local variable,  
the connection is a member variable. The calls to  
Connection.createChannel are not synchronized.

I have a shutdown listener registered on the connection, which did not  
get called. The connection seems to be alive. Without restarting the  
client or reconnecting, another attempt to publish succeeds.

We are using broker and client version 2.1.0.
Below is broker status after such an error while the client is still up.

Any ideas?

Cheers
Jiri



rabbitmqctl list_channels
Listing channels ...
<rabbit at titan.11596.0>  capacity        false   1       0
<rabbit at titan.11600.0>  capacity        false   0       0
...done.

rabbitmqctl list_connections
Listing connections ...
capacity        172.20.12.132   1187    running
...done.

rabbitmqctl status
Status of node rabbit at titan ...
[{running_applications,[{rabbit,"RabbitMQ","2.1.0"},
                         {ssl,"Erlang/OTP SSL application","4.0.1"},
                         {public_key,"Public key infrastructure","0.8"},
                         {crypto,"CRYPTO version 2","2.0.1"},
                         {os_mon,"CPO  CXC 138 46","2.2.5"},
                         {sasl,"SASL  CXC 138 11","2.1.9.2"},
                         {mnesia,"MNESIA  CXC 138 12","4.4.15"},
                         {stdlib,"ERTS  CXC 138 10","1.17.1"},
                         {kernel,"ERTS  CXC 138 10","2.14.1"}]},
  {nodes,[{disc,[rabbit at titan]}]},
  {running_nodes,[rabbit at titan]}]
...done.



More information about the rabbitmq-discuss mailing list