[openamq-dev] reply_to and routing key

Mike Owens mikeowens at gmail.com
Sun Nov 4 17:58:06 CET 2007


Martin,

Thanks for your response. I understand the basic gist of message routing and
exchange types. I think I didn't define my question well enough. In my case,
I am using the default direct exchange (amq.direct) to create a
client/server application. In this case, both client and server act as
producers and consumers.

In the simple scenario, the (application) server creates a known queue on
the direct exchange. The client creates a private queue (allowing the AMQ
server to assign the routing_key). The client sends a request to the
application server, which then needs to send the response directly back to
the client. So using the direct exchange would seem the right way to go
here, and the way the server returns messages is via the client's
routing_key.

My question is: how does the application server obtain the client's
routing_key -- which in this model seems to be the sole requirement in
getting the response back. I am not sure if this is an API or protocol
question (or both), or whether it is simply something the application must
manage. I do not see in the content class (or elsewhere) where a consumer
can infer the routing_key from a producer's message, without the producer
explicitly transferring it (either through the reply_to property, or in the
content body itself). I guess in STMP, the FROM address must be specified by
the sender, so perhaps it makes sense that the producer must specifically
supply this information as well.

It just seems that the protocol would somehow carry the producer's
routing_key information in the message somewhere. As I said, I have this
working now by making the client include its routing_key in the reply_to
property of the content it sends to the server. That is how the server can
direct its response back to the client. I just wasn't sure if there was a
more proper/elegant way to do this.

Thanks again,

Mike

On 11/4/07, Martin Sustrik <sustrik at imatix.com> wrote:
>
>
> Hi Mike,
>
> Basically, AMQP allows different ways of routing messages. You can route
> on routing-key - this is the most simple and fastest model. You can do
> 'content based routing', which means you can route messages on a table
> of name-value pairs, which is slower but more powerful.
>
> To get some idea about how the whole thing works, have a look at this
> tutorial:
>
> http://wiki.openamq.org/tutorial:understanding-amq-model
>
> For content-based routing tutorial have a look here:
>
> http://wiki.openamq.org/tutorial:content-based-routing
>
> As for reply_to, it's different from routing_key and you shouldn't
> bother with it. It's intended to JMS-over-AMQP application to implement
> JMS-style RPC messaging.
>
> Hope this helps.
> Martin
>
> On 3/11/2007, "Mike Owens" <mikeowens at gmail.com> wrote:
>
> >I just discovered AMQ (and OpenAMQ) last night. I've been an avid open
> >source uses for years, and it amazes me that this whole thing completely
> >slipped through my radar. Wonderful, wonderful software guys.
> >
> >Anyway, I've been playing the the im_receiver/im_sender examples, and I
> have
> >the receiver sending back the message to the sender. The problem is, the
> >only way I've been able to do this is by having the sender explicitly set
> >the routing-key in the content's reply_to property. It seems to me that
> >there would be some way for the receiver to obtain this information from
> the
> >content without the sender having to provide it. Again, this may be well
> >documented in the specs, but I'm still getting acquainted.
> >Thanks
> _______________________________________________
> openamq-dev mailing list
> openamq-dev at lists.openamq.org
> http://lists.openamq.org/mailman/listinfo/openamq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openamq.org/pipermail/openamq-dev/attachments/20071104/ac18bf52/attachment.htm 


More information about the openamq-dev mailing list