[rabbitmq-discuss] queue subscription + sending to some exchange
Petar Shomov
pshomov at gmail.com
Tue Jun 21 01:17:24 BST 2011
Hi Simone,
Thanx for the suggestion! I have read that section about threading
many times but my understanding is that channels can be shared among
threads as long as they are not used concurrently. I am not doing that
and I even went ahead and created that channel in the thread that is
doing the consumption just to be on the safe side. No dice, same
error.
What worries me in that section is this paragraph:
"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"
Now, does that mean I should not be doing what I intended to be doing
(I use IModel.BasicPublish)? I find that hard to believe.
I am taking care to open a different channel for the publishing of my
messages but I wonder is that enough?
My channel did not deadlock just looks like things got mixed up ;(
---------------------------------
Regards,
Petar
On Mon, Jun 20, 2011 at 9:57 PM, Simone Busoli <simone.busoli at gmail.com> wrote:
> Hi Petar,
>
> I think you are violating one of the assumption that the C# client does on
> channel usage. Channels should not be shared among threads (read the pdf
> user guide for details), and it appears you are using the channel on a
> different thread than that where the channel was created.
>
> On Mon, Jun 20, 2011 at 23:41, Petar Shomov <pshomov at gmail.com> wrote:
>>
>> Hi guys,
>>
>> I have a situation which I do not completely understand and I was
>> hoping someone more acquainted with AMQP and RabbitMQ might point me
>> in the right direction.
>>
>> I have a console app that needs to subscribe to a message queue where
>> the process of handling a message is rather lengthy. During this
>> lengthy process I need to send out messages to some exchange which
>> represent information about the progress of the operation.
>> The subscription to the queue has to be asynchronous too, since I am
>> doing something else on the main thread. So I have running in a thread
>> this code (C#):
>>
>> var job = new Thread(() =>
>> {
>> var consumer = new
>> QueueingBasicConsumer(channel);
>>
>> channel.BasicConsume(queueName, false, consumer);
>> while (true)
>> {
>> BasicDeliverEventArgs e =
>> null;
>> e =
>> (BasicDeliverEventArgs) consumer.Queue.Dequeue();
>>
>> queueHandlers[queueName][e.Exchange](e);
>>
>> channel.BasicAck(e.DeliveryTag, false);
>> }
>> }
>>
>> Unfortunately when I try to send messages within the message handler
>> (I am opening a different channel on the same connection, tried even
>> opening a different connection with no better luck) I am getting these
>> kind of exceptions, usually when attempting to send the *second*
>> message:
>>
>> - $exception {"The AMQP operation was interrupted: AMQP
>> close-reason,
>> initiated by Library, code=504, text=\"Frame received for invalid
>> channel 2\", classId=0, methodId=0,
>> cause=RabbitMQ.Client.Impl.ChannelErrorException: Frame received for
>> invalid channel 2\r\n at ...
>>
>>
>> Thoughts, ideas, anything?
>>
>> ---------------------------------
>> Regards,
>>
>> Petar
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>
More information about the rabbitmq-discuss
mailing list