Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have declared a queue with following parametrs.
channel.exchangeDeclare(EXCHANGE_NAME, ExchangeType.DIRECT.getExchangeName(), true);

Map<String, Object> args = new HashMap<String, Object>();
args.put("x-queue-mode", "lazy");

// First Queue
channel.queueDeclare(QUEUE_NAME_1, false, true, false, args);
channel.queueBind(QUEUE_NAME_1, EXCHANGE_NAME, ROUTING_KEY_1);

While sending data :
Java
channel.basicPublish(DirectExchange.EXCHANGE_NAME, DirectExchange.ROUTING_KEY_1, MessageProperties.PERSISTENT_TEXT_PLAIN, MESSAGE_1.getBytes());

Its properly storing in the local disk as well as its holding post server restart also.

But When I start my consumer its not consuming the data which is available inside the configure queue.

Following code I am using for the consumer:
Java
Connection conn = RabbitMQConnection.getConnection();
if (conn != null)
{
Channel channel = conn.createChannel();
// Consumer reading from queue 1
Consumer consumer1 = new DefaultConsumer(channel)
{
    @Override
    public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException
    {
	String message = new String(body, "UTF-8");
	System.out.println(" Message Received Queue 1 '" + message + "'");
    }
};
channel.basicConsume(DirectExchange.QUEUE_NAME_1, false, consumer1);

Kindly help me on this to resolve this issue.

Thanks,

What I have tried:

I have tried with above consumer. But its not working.
Posted
Updated 26-Jul-17 22:48pm
v2

1 solution

As per the code the queue was made as exclusive queue, so you need to use the same connection to consumer.

You need to use the Durable queue for this .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900