سؤال

we have on-premise Service Bus installation. I can publish and subscribe/read messages with QPID AMQP 1.0 0.24 client. However queue browsing doens§t work, the call to hasMoreElements() hangs indefinitely when there are no more messages in the queue. The stack trace is:

Thread [main] (Suspended)   
waiting for: ConnectionEndpoint  (id=19)    
Object.wait(long) line: not available [native method]   
ConnectionEndpoint(Object).wait() line: 503 
Receiver.drainWait() line: 533  
QueueBrowserImpl$MessageEnumeration.hasMoreElements() line: 154 
Qpid.testBrowseTopic(Connection, Context) line: 209 
Qpid.runTest(Qpid$Options) line: 93 
Qpid.main(String[]) line: 63    

The code:

ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("MS_SERVICE_BUS"); connection = connectionFactory.createConnection();

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

Queue queue = (Queue) context.lookup("MY_QUEUE");

browser = session.createBrowser(queue);

Enumeration<Message> msgs = browser.getEnumeration();

while (msgs.hasMoreElements()) {// hangs when there are no more messages
    Message message = msgs.nextElement();
    //printMessage(message);
}

The same behaviour for QPID 0.22. Is this bug in QPID client or Service Bus?

Thanks, Jan

هل كانت مفيدة؟

المحلول

There are couple things going on here:

1) Service Bus doesn't support message browse over AMQP at this time. Because the session was created with AUTO_ACKNOWLEDGE, every message you get from the Enumeration is immediately removed from the queue.

2) I have reproduced the hang in hasMoreElements() with QPid 0.25. It appears that hasMoreElements() is waiting for more messages to arrive in the queue, at least at first. If I send more messages, the loop will continue and some of the newly-arrived messages will be returned, but it stops fairly quickly. I am still investigating to determine what's going on there.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top