Return-Path: Delivered-To: apmail-activemq-dev-archive@www.apache.org Received: (qmail 8315 invoked from network); 15 Aug 2008 15:40:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Aug 2008 15:40:43 -0000 Received: (qmail 1036 invoked by uid 500); 15 Aug 2008 15:40:42 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 1016 invoked by uid 500); 15 Aug 2008 15:40:42 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 1005 invoked by uid 99); 15 Aug 2008 15:40:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Aug 2008 08:40:42 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Aug 2008 15:39:54 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id B4707234C1B5 for ; Fri, 15 Aug 2008 08:39:52 -0700 (PDT) Message-ID: <926692187.1218814792737.JavaMail.jira@brutus> Date: Fri, 15 Aug 2008 08:39:52 -0700 (PDT) From: "PJ Fanning (JIRA)" To: dev@activemq.apache.org Subject: [jira] Commented: (AMQ-1850) Failing to close a connection leaves consumers behind that prevent new consumers receiving messages In-Reply-To: <1324016368.1215643800296.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/activemq/browse/AMQ-1850?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44988#action_44988 ] PJ Fanning commented on AMQ-1850: --------------------------------- Thanks for the advice, Rob. Using queueName?consumer.prefetchSize=0 means that my (artificial) test case passes. I still think it would be a good feature if consumers and connections were timed out by the ActiveMQ server if the client goes offline. > Failing to close a connection leaves consumers behind that prevent new consumers receiving messages > --------------------------------------------------------------------------------------------------- > > Key: AMQ-1850 > URL: https://issues.apache.org/activemq/browse/AMQ-1850 > Project: ActiveMQ > Issue Type: Bug > Components: Broker > Affects Versions: 4.1.0, 4.1.1, 4.1.2, 5.0.0, 5.1.0 > Reporter: Denis Abramov > Assignee: Rob Davies > Priority: Blocker > Attachments: TestAmq.java > > > I have been having this problem throughout all of the ActiveMQ versions (starting from 4.1.0-incubator). Just got used to killing off the dead clients throught jconsole every morning. Would be nice to have this fixed... Glad someone put a test case for it [thanks Ossory] > Hi, > I have an issue where a JMS client attempts to receive messages from a queue. The client fails due to a JVM crash and the JMS connection is not closed. This leaves a consumer behind (that I can see in the ActiveMQ admin console). If I restart the JMS client it fails to receive all of the new messages that sent to the queue in question. > Using JMX to stop the open connections or closing ActiveMQ allows the client to work again. > Is there a timeout value that you can apply to connections to avoid having to do this? > Any help would be appreciated. > I've created an artificial test case based on the behaviour I have seen in ActiveMQ 5.1 on Windows XP. > The method jmsTest2 deliberately fails to close the connection. > static final String PROVIDER_URL = "tcp://localhost:61616"; > static final String QUEUE = "queueA"; > static void jmsTest() throws JMSException, NamingException { > Properties props = new Properties(); > props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); > props.setProperty(Context.PROVIDER_URL, PROVIDER_URL); > InitialContext ctx = new InitialContext(props); > QueueConnectionFactory cf = (QueueConnectionFactory)ctx.lookup("ConnectionFactory"); > QueueConnection conn = cf.createQueueConnection(); > conn.start(); //this is required if you want to receive messages using this connection > QueueSession sess = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); > Queue qa = sess.createQueue(QUEUE); > QueueSender sender = sess.createSender(qa); > for(int i = 0; i < 10; i++) { > Message msg = sess.createTextMessage("test"); > sender.send(msg); > } > sender.close(); > sess.close(); > conn.close(); > } > static void jmsTest2() throws JMSException, NamingException { > Properties props = new Properties(); > props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); > props.setProperty(Context.PROVIDER_URL, PROVIDER_URL); > InitialContext ctx = new InitialContext(props); > QueueConnectionFactory cf = (QueueConnectionFactory)ctx.lookup("ConnectionFactory"); > QueueConnection conn = cf.createQueueConnection(); > conn.start(); //this is required if you want to receive messages using this connection > QueueSession sess = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); > Queue qa = sess.createQueue(QUEUE); > QueueReceiver qr = sess.createReceiver(qa); > for(int i = 0; i < 10; i++) { > Message msgin = qr.receive(5000); > System.out.println("msgin" + i + " = " + msgin); > } > //qr.close(); > //sess.close(); > //conn.stop(); > //conn.close(); > } > public static void main(String[] args) > { > jmsTest(); > jmsTest2(); > jmsTest(); > jmsTest2(); > } > The first call to jmsTest2 prints 10 messages but the second call fails to read any messages. The JVM will not stop after the main method completes because some ActiveMQ threads remain open. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.