[rabbitmq-discuss] queue subscription + sending to some exchange
Petar Shomov
pshomov at gmail.com
Wed Jun 22 02:19:32 BST 2011
Hi Emile,
What a great suggestion: look into the log file ;). Indeed I looked
and found the problem: the exchange I was posting to did not exist.
Somehow the first posting succeeded but on the second attempt did not
go through or something like that.
I am going to post the mini-example just in case since I prepared it
anyways so it might be useful to someone. I find the error message in
the rabbitmq server log very helpful but the one that I got in the
client was very confusing - 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
Thank you and Simone for reaching out!
---------------------------------
Regards,
Petar
On Tue, Jun 21, 2011 at 9:40 AM, Emile Joubert <emile at rabbitmq.com> wrote:
> Hi Petar,
>
> I assume that queueHandlers in your snippet establishes a new channel
> when the error occurs. Is it possible that queueHandlers is using the
> wrong channel by mistake? Can you supply a minimal self-contained
> example that illustrates the problem? Is there any additional
> information in the broker logfile at the time of the error?
>
>
> -Emile
>
>
> On 21/06/11 01:17, Petar Shomov wrote:
>> 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?
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Sample.Test.zip
Type: application/zip
Size: 4034 bytes
Desc: not available
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110622/98273bde/attachment.zip>
More information about the rabbitmq-discuss
mailing list