[rabbitmq-discuss] Java client: channel synchronization deadlock?

Jonathan McGee jon at arithum.com
Fri Dec 12 21:06:20 GMT 2008


This is my first post to the list.  Thanks for creating this  
incredible software!

I've been following the Java API guide here http://www.rabbitmq.com/ 

In the guide it recommends "If more than one thread needs to access a  
particular Channel instance, the application should enforce mutual  
exclusion itself, for example by synchronising on the Channel."

I did exactly this, however the following code causes a deadlock:

synchronized(channel) {

It appears this is because the RabbitMQ client does its own locking  
on "this" internally.

I'm wondering if the RabbitMQ client was updated to become thread- 
safe, and the guide is simply out of date?  When I remove the  
synchronization, things work fine.  Is the API actually 100% thread- 
safe now, or would you still recommend synchronizing on a separate  
object other than the Channel itself?

(As a side note, the guide also indicates that you must obtain a  
ticket to access a Channel, but this doesn't seem to be required  


More information about the rabbitmq-discuss mailing list