[rabbitmq-discuss] pub-sub part 2: erlang consume
Ben Hood
0x6e6562 at gmail.com
Thu Apr 10 22:40:46 BST 2008
Joe,
On 10 Apr 2008, at 21:18, Joe Lee wrote:
> Does null queue have any special functionality?
>
Not really. As you correctly observe below, the expected behaviour of
passing an empty queue name is that the broker fills this in for you
and tells you what name it gave the queue. This is also the behaviour
of RabbitMQ.
>
> Abstract from the amqp docs:
>
> 2.1.5.3 Constructing a PubSub
> Subscription Queue
>
> Here is the pseudocode
> for creating and binding the pubsub subscription queue:
> Queue.Declare
> queue=<empty>
> auto_delete=TRUE
> S:Queue.Declare-Ok
> queue=tmp.2
> Queue.Bind
> queue=tmp.2
> TO exchange=amq.topic
> WHERE routing_key=STOCK.USD.*
>
> To consume from the subscription queue, the consumer does this:
>
> Basic.Consume
> queue=tmp.2
>
> When publishing a message, the producer does something like this:
>
> Basic.Publish
> exchange=amq.topic
> routing_key=STOCK.USD.IBM
>
>
> Maybe you can tell us what you are trying to achieve.
>
> I just want to do simple publish a message and then consume the
> message.
This will work with Rabbit. The issue I think you are have is not to
do with non-compliance with the specification.
As I said in my previous mail, I think you have a bug in your code
where you match the response of the queue declare call.
In your code, one of the fields of the tuple you are matching on is
already bound, and as Erlang doesn't allow destructive assignment, it
treats the assignment operator in this context as a comparison.
The way to fix this is the following:
'queue.declare_ok'{
%% Don't use the previously bound variable called Q to store
the
%% queue name field because the Erlang runtime will complain
queue = SomeVariableNameOtherThanTheOneYouPreviouslyAssigned,
message_count = MessageCount,
consumer_count = ConsumerCount}
= amqp_channel:call(Channel,QueueDeclare)
and then perform a basic consume using the value stored in the
variable "SomeVariableNameOtherThanTheOneYouPreviouslyAssigned".
HTH,
Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20080410/65236243/attachment.htm
More information about the rabbitmq-discuss
mailing list