Return-Path: X-Original-To: apmail-activemq-users-archive@www.apache.org Delivered-To: apmail-activemq-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3F63110131 for ; Thu, 26 Sep 2013 20:09:42 +0000 (UTC) Received: (qmail 33253 invoked by uid 500); 26 Sep 2013 20:09:39 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 33188 invoked by uid 500); 26 Sep 2013 20:09:34 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 33150 invoked by uid 99); 26 Sep 2013 20:09:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Sep 2013 20:09:32 +0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [216.139.250.139] (HELO joe.nabble.com) (216.139.250.139) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Sep 2013 20:09:23 +0000 Received: from [192.168.236.139] (helo=joe.nabble.com) by joe.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1VPHrZ-0000fE-Ja for users@activemq.apache.org; Thu, 26 Sep 2013 13:08:37 -0700 Date: Thu, 26 Sep 2013 13:08:22 -0700 (PDT) From: zbc To: users@activemq.apache.org Message-ID: <1380226102517-4671868.post@n4.nabble.com> Subject: standard jms code can not receive message from queue MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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.