[rabbitmq-discuss] Connection Closing when used by more that one exchange

Marcus Vinitius Baffa mbaffa at opus.com.br
Tue Jun 14 20:16:23 BST 2011

Hi Emile,

It worked. The problem was the using block. I was opening the connection
and the channel in a using block. When the block lessed scope, in the
first message the connection was closed, and the second message that
should use this connection caused the error.

I have removed the using blocks and everything is working OK.


-----Original Message-----
From: Emile Joubert [mailto:emile at rabbitmq.com] 
Sent: Friday, June 10, 2011 9:14 AM
To: Marcus Vinitius Baffa
Cc: rabbitmq-discuss at lists.rabbitmq.com
Subject: Re: [rabbitmq-discuss] Connection Closing when used by more
that one exchange

Hi Marcus,

On 07/06/11 18:12, Marcus Vinitius Baffa wrote:

> As you can see the sendReply opens another connection and channel to
> send the reply back to the consumer. I know I can use the RPC pattern
> but I need to send a message back like this.

You code does execute, but the peak performance achievable will be
limited, because you are establishing a new channel for each reply.

> When I try to define one connection that would be used by the
> receiveMessageAmqp and the sendReply it stops working.

This works fine for me when I modify your example to use the same
connection for both receiver and sender.

> What happens is that the first message received everything works ok,
> message is received and the reply is sent. When another message is
> by the producer the consumer receives the message and the line
> channel.BasicAck( basicDeliveryEventArgs.DeliveryTag, false ); is
> executed an exception is thrown:

Are you perhaps acknowledging the same message twice? Does the broker
logfile contain anything useful around the time this happens?

> base {RabbitMQ.Client.Exceptions.OperationInterruptedException} =
> AMQP operation was interrupted: AMQP close-reason, initiated by
> Application, code=200, text=\"Connection close forced\", classId=0,
> methodId=0, cause="}

"initiated by Application" normally means a shutdown initiated by the
application using the library, but I'm not sure I believe it in this
case. Your code traps and ignores exceptions in many places - are you
sure the real reason is masked in that way?


More information about the rabbitmq-discuss mailing list