[rabbitmq-discuss] Erlang Client - Possible to recover routing key?

Schlomer, Loren Loren.Schlomer at echostar.com
Fri Apr 17 19:02:14 BST 2009


Hello,

 

I am writing an intelligent notification system, which pulls messages
off of amqp, parses the routing key and decides what users to send the
notification to.  The trouble is, the routing keys can be anywhere up to
10 segments and can be literally millions of different combinations.  I
am, of course, able to subscribe to the queue and retrieve all the
messages using wildcards.

 

The issue and question I have ---

I need the routing key the message was published with in order to parse
the notification.  Looking at the network traffic, the routing key is
included, but it seems to get lost somewhere in the client code.  The
tuple returned from lib_amqp:get/3 only seems to include the mime-type
and the Payload.

 

Is there a way to retrieve the routing key when pulling messages off a
queue?

 

%% sample code %%

 

%% Producer

Connection = lib_amqp:start_connection("localhost"),

Channel = lib_amqp:start_channel(Connection),

lib_amqp:declare_exchange(Channel, <<"test.exchange">>, <<"topic">>),

 

lib_amqp:publish(Channel, <<"test.exchange">>, <<"routing.key">>,
term_to_binary(Message)).

 

 

 

%% Consumer

Connection = lib_amqp:start_connection("localhost"),

Channel = lib_amqp:start_channel(Connection),

lib_amqp:declare_exchange(Channel, <<"test.exchange">>, <<"topic">>),

 

Queue = lib_amqp:declare_queue(Channel, <<"routing.*"">>),

lib_amqp:bind_queue(Channel, <<"test.exchange">>, Queue,
<<"routing.*">>,

 

 

Reply = lib_amqp:get(Channel, Queue, false),

 

 

--- Or am I way off on all of this?

 

 

Thank you!

 

-ls

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20090417/0058bd16/attachment.htm 


More information about the rabbitmq-discuss mailing list