[rabbitmq-discuss] synchronized messages: through the queue and multiple consumers

Tony Garnock-Jones tonyg at lshift.net
Thu Jan 17 12:03:50 GMT 2008


Hi Joe,

joe lee wrote:
> I have two producers that need to send synchronized message to a queue,
> where 1 of 3 consumers will consume the message.  In this scenario,
> would the producer who sent the message, waits for the status back from
> the consumer, that consumed the message?

There's no provision for this kind of synchronisation embedded in AMQP,
but it's the kind of thing that's easy to construct on top of AMQP.

> In synchronized messaging,
> would producer and consumer talk directly to each other or the message
> put in queue and consumer consume and reply back to the waiting producer?

The latter - every communication is mediated by a queue.

One way you could get what I think you're after would be to have a setup
like the following diagram, where consumers get handed work items
round-robin from the queue, and each item has a queue name in the
"reply-to" field of the Basic Properties content header. When the
consumer finishes the job, it replies to the producer by inserting a
message in the reply queue found in the request, with the reply's
"correlation-id" field set equal to the "correlation-id" field of the
request. See, for example, classes RpcClient and RpcServer in the main
RabbitMQ java client library.


	Producer   -----------------------\
	    ^				   \
	    |	  		      	    \
	       	  			     |
       	Producer's			     |
       	reply				     |
       	queue				     v

	    ^				Service exchange
	    |
	    |
	    |				     |
	    |				     |
	    |				     v
	    |
	    | 			      Service queue
	    |
	    | 				     |
	    | 				     |
	    | 				     v
	    | 				     |
	    | 		              /------+------\
	    | 		             /       |	     \
	    | 		            |        |	      |
	    | 		            |        |	      |
	    |		            |        |	      |
	    |		            v  	     v 	      v
	    |
 	    |		 Consumers: 1        2        3
	    |
	     \ 					      |
	      \					      /
	       \--------------------------------------


Regards,
  Tony
-- 
 [][][] Tony Garnock-Jones     | Mob: +44 (0)7905 974 211
   [][] LShift Ltd             | Tel: +44 (0)20 7729 7060
 []  [] http://www.lshift.net/ | Email: tonyg at lshift.net




More information about the rabbitmq-discuss mailing list