[rabbitmq-discuss] pub-sub part 2: erlang consume

Ben Hood 0x6e6562 at gmail.com
Fri Apr 11 06:36:16 BST 2008


On 11 Apr 2008, at 05:24, Joe Lee wrote:

> Hello all,
>
> On Thu, Apr 10, 2008 at 6:55 AM, Ben Hood <0x6e6562 at gmail.com> wrote:
> You are trying to match this tuple
>
>
> #'queue.declare_ok'{queue = Q,
>                        message_count = MessageCount,
>                        consumer_count = ConsumerCount}
>                       = amqp_channel:call(Channel,QueueDeclare)
>
> with this tuple:
>
>
> {'queue.declare_ok',
>                         <<"amq.q.gen1_rabbit at home_20080409224223_">>, 
> 0,0}
>
>
> so that fact that Q, which was previously bound to <<"">> is being  
> compared to <"amq.q.gen1_rabbit at home_20080409224223_">> which  
> violates the match condition.
>
> To fix this, don't re-use the *variable* Q, because in Erlang, it's  
> not really a variable (non-destructive assignment).
>
> I have tried what Ben suggested and used a new variable called Q1.   
> It helped me get over that problem.  Now I have another issue with  
> the consume code.
>
> I tried looking into mnesia tables and ets tables, but not much  
> help.  Receive is timing out at after 2000 ->   
> exit(did_not_receive_message) end.  Only reason for to get timeout  
> is when there isn't a message in the exchange.  This shouldn't be  
> the case because I just published the message.
>
>  receive
>         {#'basic.deliver'{delivery_tag = DeliveryTag}, Content} ->
>             #content{payload_fragments_rev = [Payload]} = Content,
>             io:format("Message received: ~p~n", [Payload])
>     after 2000 ->
>         exit(did_not_receive_message)
>     end

f you are using the same code that you posted yesterday, this won't  
work because you are consuming from the wrong queue:

BasicConsume = #'basic.consume'{ticket = Ticket,
                                     queue = Q,
                                     consumer_tag = <<"">>,
                                     no_local = false,
                                     no_ack = true,
                                     exclusive = false,
                                     nowait = false},
     #'basic.consume_ok'{consumer_tag = ConsumerTag}
         = amqp_channel:call(Channel, BasicConsume, self()),

You need to consume from the queue whose name you stored in Q1.

HTH,

Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20080411/86b94c19/attachment.htm 


More information about the rabbitmq-discuss mailing list