[rabbitmq-discuss] Creating exchanges on demand.

Camilo Lopez camilol at gmail.com
Mon Jun 8 21:07:04 BST 2009


Thanks a lot Matthias,

I was trying to make sense of the Java code, I very rarely (if ever) use Java.

On Mon, Jun 8, 2009 at 3:44 PM, Matthias Radestock <matthias at lshift.net> wrote:
> Camilo,
>
> Camilo Lopez wrote:
>>
>> Appart from the rpc facilities  in the clients is there a good pattern
>> to follow here?
>
> The rpc wrappers actually implement a very straightforward pattern. Take a
> look at the code for Rpc{Client,Server}.java.
>
> The pattern is this:
>
> The server creates a queue for requests and binds that queue to an exchange.
> In the simplest case, the queue is named after the rpc service and the
> standard binding to AMQP's default exchange suffices - that's what I am
> assuming below. The server subscribes a consumer to that queue.
>
> Each client creates a (usually anonymous and exclusive) queue for replies
> and subscribes a consumer (usually with noAck=true) to that queue.
>
> RPCs then happen as follows:
>
> 1. The client publishes the request as a message to the default exchange
> with a routing key identifying the rpc service, the request as the payload,
> and two message properties (see
> http://www.rabbitmq.com/releases/rabbitmq-java-client/v1.5.5/rabbitmq-java-client-javadoc-1.5.5/com/rabbitmq/client/AMQP.BasicProperties.html)
> a correlationId that identifies the requests (this is only necessary if the
> client wants to pipeline requests), and a replyTo property set to its reply
> queue name.
>
> 2. The server's consumer receives the request, performs the necessary
> invocations, and then publishes the reply to the default exchange with the
> routing key set to the value of the replyTo property of the request, and the
> correlationId message property set to the correlationId property of the
> request. The client then basic.ack's the request.
>
> 3. The client's consumer receives the reply, and correlates it with the
> request using the correlationId.
>
>
> Regards,
>
> Matthias.
>




More information about the rabbitmq-discuss mailing list