[openamq-dev] reply_to and routing key
Martin Lucina
mato at imatix.com
Sun Nov 4 18:24:25 CET 2007
Mike,
mikeowens at gmail.com said:
> 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
> [...]
> 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.
Your reasoning is correct. The content reply-to property is the only
method a service can use to determine the sender of the message. It's
also the standard way to do this, since you can follow reply_to when
e.g. debugging the client/server with a non-zero trace level (-t X).
It is up to the application to set this when creating the content.
Generally speaking, in a simple client/server scenario, what you will
want to do on the client side is this:
1) Issue a queue.declare (ticket=0, queue="", passive=0, durable=0,
exclusive=0, auto_delete=1, nowait=0,
arguments="")
(You might want exclusive=1 as well)
2) Save the value of s_session->queue. This will be something like
"#1", and is the unique routing key for your client's queue.
3) When creating content, call
amq_content_basic_set_reply_to (basic_content, <saved queue name>);
Hope this answers your question.
-mato
More information about the openamq-dev
mailing list