[rabbitmq-discuss] Redeliever message with path in exchange to exchange binding
Son Tran-Nguyen
esente at gmail.com
Fri Oct 5 21:42:15 BST 2012
Hi,
I am trying to write a custom exchange type in which when bound to another
exchange, it will change the message so that the final queue will also know
which path the message were routes to.
For example, A is bound to B so that message published to A will be routed
to B and come to any queue bound to B. But when it's turn for B to route to
its queue, it will either change the exchange_name of the #basic_message,
or add B to a path tuple in the headers.
However, I failed to do such a thing. My custom exchange has the route/2 as
following:
route(X=#exchange{ name = XName},
D=#delivery{ message = #basic_message{exchange_name = XName }}) ->
Exchange = exchange_type(X), % a helper to detect the actual exchange
type, default to topic
Exchange:route(X, D);
route(X=#exchange{ name = XName},
D=#delivery{ msg_seq_no = MsgSeqNo,
message = BasicMsg = #basic_message{
exchange_name = Followee,
routing_keys = [Key], content = Content }}) ->
% Change the delivery here to NewDelivery
Exchange = exchange_type(X),
Exchange:route(X, NewDelivery).
I thought that when the message is published to the first exchange, it will
find all the bound destinations, including the bound exchange, and route
message there. When I debug it, I see that the second route/2 function
clause is also called, so the message should be routed and delivered to any
bound queues/exchanges of the second exchange. I also make sure to change
the message id, message sequence number to make sure I have a total
different message.
However, the queue bound to the second exchange only receives one message
from the first exchange.
Can anybody help me with this?
Sincerely,
Son Tran-Nguyen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121005/f70e6cad/attachment.htm>
More information about the rabbitmq-discuss
mailing list