qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Venkat Rangan <ven...@clariussystems.com>
Subject Using the same producer multiple times does not work...
Date Tue, 11 Dec 2012 19:15:21 GMT
Hi,


I have a situation where I reuse the same destination queue for multiple
producers. What I am finding is that if I do this, the second instance
message is stuck and is not available for the MessageConsumer. Assume that
there is a connection that is started. I would have expected both test1()
and test2() below to succeed. What I observe is that the test2() is stuck
on the consumer.receive(). Also, is there a way to "commit" the send
without a producer.close() and would that make the second instance of the
test below also have the receive() pull out the message?


Thanks!


       public void test1() {

Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE
);;

Destination queue = new AMQAnyDestination("ADDR:testQueue; {create: always}"
);

MessageProducer producer = session.createProducer(queue);

TextMessage msg = session.createTextMessage("hello, world-1");

producer.send(msg);

producer.close();

MessageConsumer consumer = session.createConsumer(queue);

TextMessage recvdMessage = (TextMessage)consumer.receive();

System.out.println("Received: " + recvdMessage.getText());

}


 public void test2() {

Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE
);;

Destination queue = new AMQAnyDestination("ADDR:testQueue; {create: always}"
);

MessageProducer producer = session.createProducer(queue);

TextMessage msg = session.createTextMessage("hello, world-2");

producer.send(msg);

producer.close();

MessageConsumer consumer = session.createConsumer(queue);

TextMessage recvdMessage = (TextMessage)consumer.receive();

System.out.println("Received: " + recvdMessage.getText());

}

Thanks!

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message