[rabbitmq-discuss] Channel thread safety in Java Client

Tony Garnock-Jones tonyg at lshift.net
Fri Jul 17 14:18:13 BST 2009


tsuraan wrote:
> I could do that.  I'd just have to keep track of which channel each
> message came from.

FYI, any subclass of DefaultConsumer has getChannel(), which returns the
channel that the Consumer is associated with. So, for example, given a
QueueingConsumer "qc":

 while (true) {
  QueueingConsumer.Delivery delivery = qc.nextDelivery();
  System.out.println("Message: " + new String(delivery.getBody()));
  qc.getChannel().basicAck(delivery.getEnvelope().getDeliveryTag(),
                           false);
 }

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