please look at following code: InitialContext ctx = null; QueueConnection con = null; QueueSession queueSession = null; QueueReceiver receiver = null; try { Hashtable env = new Hashtable(); env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); env.put(Context.PROVIDER_URL, "tcp://localhost:61616"); ctx = new InitialContext(env); QueueConnectionFactory fac = (QueueConnectionFactory)ctx.lookup("ConnectionFactory"); con = fac.createQueueConnection(); queueSession = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); con.start(); receiver = queueSession.createReceiver((Queue)ctx.lookup("dynamicQueues/FromReqRespClient")); Message result = receiver.receiveNoWait(); System.out.println(result); } catch (Exception e) { e.printStackTrace(); } finally { close(); }
this is standard jms code, but it can NOT receive message from queue, if you add a line "Thread.sleep(500)" before "Message result = receiver.receiveNoWait(); ", it WORKS. this code work well to openJMS, is it a bug? you can try yourself, thanks. -- View this message in context: http://activemq.2283324.n4.nabble.com/standard-jms-code-can-not-receive-message-from-queue-tp4671868.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.