[rabbitmq-discuss] IModel thread safety in.NET client
emile at rabbitmq.com
Thu Oct 13 18:15:06 BST 2011
On 13/10/11 17:17, TrueWill wrote:
> Thank you for your response.
> I'm still confused, though. The rabbitmq-dotnet-client-2.6.1-user-guide
> states (p. 11):
> "Application callback handlers /must not/ invoke blocking AMQP
> operations (such as
> IModel.QueueDeclare, IModel.BasicCancel or IModel.BasicPublish). If they
> do, the channel
> will deadlock."
> Could you please clarify?
Yes. If you issue any synchronous commands from a handler then the
channel will immediately deadlock. Publish could deadlock only if
channel flow was asserted by the broker, but recent versions of the
broker (since 2.0.0) use TCP back pressure instead of channel
flow-control. If you want interoperability with other brokers that might
use channel flow-control then you should avoid publish within a handler.
Be aware that TCP back pressure will block asynchronous methods like
ack, without causing the channel to deadlock, and back pressure affects
all channels sharing the connection.
The safest approach is to use the QueueingBasicConsumer with BasicQos to
prevent the client from receiving too many messages at once.
More information about the rabbitmq-discuss