[rabbitmq-discuss] consuming a message from exchange does not seem to work on java client (3.2.0 as well as 3.1.5)

Murugesan Guruswamy murugesan at elementum.com
Mon Nov 4 16:41:07 GMT 2013


Michael,


I am using "test.abc" as routing key for both Publish and consume. I had put the comments below on what values are used for queueName, routingKey and exchangeName. For basicPublish, I am not using any queue.bind since this is publishing to exchange.

Only the consumer is using the queue.bind on the queueName, exchangeName.

Any help:
Publish code:
		Connection conn = factory.newConnection(addr);
		Channel channel = conn.createChannel();
		channel.exchangeDeclare("localExchange", "topic", true); // durable
		channel.basicPublish("localExchange", "test.abc", null, msg.getBytes());

Consumer code:
		Connection conn = factory.newConnection(addr);
		Channel channel = conn.createChannel();
		channel.exchangeDeclare("localExchange", "direct", true);
		channel.queueDeclare("Notification", true, false, false, null);
		channel.queueBind("Notification", "localExchange", "test.abc");
		QueueingConsumer qCon = new QueueingConsumer(channel);
                channel.basicConsume("Notification", false, qCon);
		while (true) {
		   Delivery delivery = qCon.nextDelivery();
		   System.out.println("[x] " + new String(delivery.getBody()) + " " + delivery.getEnvelope().getRoutingKey());	
		   qCon.getChannel().basicAck(delivery.getEnvelope().getDeliveryTag(), false);
		}
                


Any suggestions?

Thx,
Murugesan

                


On Nov 4, 2013, at 8:12 AM, Michael Klishin <mklishin at gopivotal.com> wrote:

> 
> On 4 Nov 2013, at 10:22, Murugesan Guruswamy <murugesan at elementum.com> wrote:
> 
>> Routing key : "test.abc", queueName : Notification, exchangeName : localExchange.
>> 
>> Is there any rabbitmq-server configurations to do?
> 
> Direct and topic exchange route message based on routing key of the message.
> Your example does not show if the key used in queue.bind matches the one used in basic.publish
> but it’s very likely to be the issue.
> 
> Also, you do not consume messages from exchanges.
> 
> See tutorials 3-5 for more info http://www.rabbitmq.com/getstarted.html
> and http://www.rabbitmq.com/tutorials/amqp-concepts.html.
> 
> Use RabbitMQ management UI to see bindings, message rates and more:
> http://www.rabbitmq.com/management.html
> 
> MK
> 
> Software Engineer, Pivotal/RabbitMQ
> 
> 


-- 
 

Legal Disclaimer: The information contained in this message may be 
privileged and confidential. It is intended to be read only by the 
individual or entity to whom it is addressed or by their designee. If the 
reader of this message is not the intended recipient, you are on notice 
that any distribution of this message, in any form, is strictly prohibited. 
If you have received this message in error, please immediately notify the 
sender and delete or destroy any copy of this message 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20131104/830fb96e/attachment.htm>


More information about the rabbitmq-discuss mailing list