[rabbitmq-discuss] .Net Client locks trying to create a channel on a blocked connection
Kenneth Ross
K.Ross at Resilientplc.com
Thu Aug 23 15:45:45 BST 2012
I'm using the RabbitMQ .Net client in C# and have noticed that if I try to create a channel (IModel) on a connection that is already established but in a blocking state then the code will just sit and wait.
Here is the C# code, nothing special:
IModel channel = connection.CreateModel();
I've taken a look at the source of the RabbitMQ .Net Client and have traced it down to this:
Calling CreateModel() does the following:
public IModel CreateModel()
{
ISession session = CreateSession();
IFullModel model = (IFullModel)Protocol.CreateModel(session);
model._Private_ChannelOpen("");
return model;
}
When model._Private_ChannelOpen(""); is called it ends up in this block of code:
SimpleBlockingRpcContinuation k = new SimpleBlockingRpcContinuation();
TransmitAndEnqueue(new Command(method, header, body), k);
return k.GetReply().Method;
The problem appears to be with the last line, which ends up trying to get the Value of a BlockingCell object, which is basically a while(true) loop like this:
get {
lock (this) {
while (!m_valueSet) {
Monitor.Wait(this);
}
return m_value;
}
}
And because the m_valueSet is never true this code never returns :-( and the call to CreateModel stays in a blocked condition - presumably until the connection is unblocked.
Does anyone have any advice on how best to handle this situation?
Many thanks!
More information about the rabbitmq-discuss
mailing list