Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 41152 invoked from network); 13 Jun 2008 20:34:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Jun 2008 20:34:08 -0000 Received: (qmail 29188 invoked by uid 500); 13 Jun 2008 20:34:09 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 29167 invoked by uid 500); 13 Jun 2008 20:34:09 -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 29150 invoked by uid 99); 13 Jun 2008 20:34:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jun 2008 13:34:09 -0700 X-ASF-Spam-Status: No, hits=3.7 required=10.0 tests=HTML_MESSAGE,NORMAL_HTTP_TO_IP,SPF_PASS,WEIRD_PORT,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of dstanleyd@gmail.com designates 209.85.198.246 as permitted sender) Received: from [209.85.198.246] (HELO rv-out-0708.google.com) (209.85.198.246) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jun 2008 20:33:19 +0000 Received: by rv-out-0708.google.com with SMTP id f25so5938842rvb.26 for ; Fri, 13 Jun 2008 13:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=pjUgQMyn0ZCuFRsQvvX6KtxA8rhJUdcUGFJI0M7Puk4=; b=mpVqLqO0GdDpnbVoUCZz6HUOz6231SuuSkqVdW9yH5Qp+BzZAuaVrnnsDeKsiJrHyW 4MY4b6M9dpa+KtzJEVaMUfNhTmsQfaEx3CI+QF/867KWcLMbIVL8Up/ZCvhHB0+P5AwT /XlxvzvVfKLL21pzGY5kJTgDEz0FWNRqijeVk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=v6Kxc4Bt6lNlKOup+eW3IdJlgIMKa6HEG79QgyaH8U9m7cLods6i9c1TnXuUoAToMk Xys7XH+vK2BLDlXH+toterXHpUbqJXngavNpc+FvBSQYiwhs2cE3zuPmuyNgPtsI1zsN JwfF59Sdjzyg6NPw9lHsQNmenEGrQhTyO/EfQ= Received: by 10.141.85.13 with SMTP id n13mr2107169rvl.250.1213389217031; Fri, 13 Jun 2008 13:33:37 -0700 (PDT) Received: by 10.140.204.12 with HTTP; Fri, 13 Jun 2008 13:33:36 -0700 (PDT) Message-ID: <2e6260670806131333y527ccbffvc63a7170551fa575@mail.gmail.com> Date: Fri, 13 Jun 2008 16:33:36 -0400 From: "Dave Stanley" To: users@activemq.apache.org Subject: Re: having problem with durable subscription In-Reply-To: <17828072.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_6158_20218832.1213389217027" References: <17813954.post@talk.nabble.com> <2e6260670806130853i76d9700el5c89e7f253a83583@mail.gmail.com> <17827792.post@talk.nabble.com> <17828072.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_6158_20218832.1213389217027 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Not that it helps much, I tried it with a 5.x release and your code works fine. I see the subscription is durable across consumer and broker restarts. Have you modified your activemq.xml, are you running with 5.1.0? /Dave On Fri, Jun 13, 2008 at 1:05 PM, eaglepointe wrote: > > Forgot to mention that I also restarted message broker before start durable > subscriber again. > > > eaglepointe wrote: > > > > Ok, here is what I did, > > > > 1) start message broker > > 2) start a durable subscriber which subscribes "topictest.messages" as > the > > attached code > > 3) start publisher, which sends some messages to "topictest.messages" in > > 'persistent' mode, and the subscriber receives the messages > > 4) stop the subscriber and publisher > > 5) start publisher again, which sends some messages to > > "topictest.messages" > > 6) stop publisher > > 7) start subscriber again, according to my understanding of durable > > subscription, I'd expect subscriber receives the messages sent by > > publisher, but I got the exceptions instead > > > > Following is a more complete version of subscriber code, which is really > > the sample code comes with ActiveMQ installation, except for the durable > > subscription. > > > > The same code works fine, meaning no exceptions, if I don't use durable > > subscription. > > It seems that durable subscription requires some context in message > broker > > which somehow got lost. > > > > > > > -------------------------------------------------------------------------------------------- > > > > public class TopicListener implements MessageListener { > > > > private Connection connection; > > private MessageProducer producer; > > private Session session; > > private int count; > > private long start; > > private Topic topic; > > private Topic control; > > //private TopicSubscriber consumer; > > > > private String url = "tcp://192.168.30.60:61616"; > > > > public static void main(String[] argv) throws Exception { > > TopicListener l = new TopicListener(); > > String[] unknown = CommandLineSupport.setOptions(l, argv); > > if (unknown.length > 0) { > > System.out.println("Unknown options: " + > > Arrays.toString(unknown)); > > System.exit(-1); > > } > > l.run(); > > } > > > > public void run() throws JMSException { > > ActiveMQConnectionFactory factory = new > > ActiveMQConnectionFactory(url); > > connection = factory.createConnection(); > > connection.setClientID("myClient"); > > session = connection.createSession(false, > > Session.AUTO_ACKNOWLEDGE); > > topic = session.createTopic("topictest.messages"); > > control = session.createTopic("topictest.control"); > > > > TopicSubscriber consumer = > > session.createDurableSubscriber(topic,"myDurable1"); > > //MessageConsumer consumer = session.createConsumer(topic); > > consumer.setMessageListener(this); > > > > producer = session.createProducer(control); > > > > System.out.println("Waiting for messages..."); > > connection.start(); > > } > > > --------------------------------------------------------------------------------- > > > > your grateful, > > -Jeff > > > > > > > > Dave Stanley wrote: > >> > >> Your not running this from within a thread by any chance? I don't > >> believe connection.start() is going to block, so try and create the > >> connection outside the thread and pass it in by reference to the thread > >> instance. > >> > >> HTH > >> /Dave > >> > >> > >> On Thu, Jun 12, 2008 at 10:30 PM, eaglepointe > >> wrote: > >> > >>> > >>> Hi, > >>> > >>> I'm new to ActiveMQ and having problem with durable subscription, > >>> following > >>> code based on example code, > >>> > >>> =================================================================== > >>> public void run() throws JMSException { > >>> ActiveMQConnectionFactory factory = new > >>> ActiveMQConnectionFactory(url); > >>> connection = factory.createConnection(); > >>> connection.setClientID("myClient"); > >>> session = connection.createSession(false, > >>> Session.AUTO_ACKNOWLEDGE); > >>> topic = session.createTopic("topictest.messages"); > >>> control = session.createTopic("topictest.control"); > >>> > >>> TopicSubscriber consumer = > >>> session.createDurableSubscriber(topic,"myDurable1"); > >>> //MessageConsumer consumer = session.createConsumer(topic); > >>> consumer.setMessageListener(this); > >>> > >>> producer = session.createProducer(control); > >>> > >>> System.out.println("Waiting for messages..."); > >>> connection.start(); > >>> } > >>> ================================================================= > >>> > >>> is causing exceptions on broker side and client side, below are the > >>> exceptions > >>> > >>> broker side: > >>> > >>> ERROR Service - Async error occurred: > >>> java.lang.NullPointerException > >>> java.lang.NullPointerException > >>> at > >>> > >>> > org.apache.activemq.broker.TransportConnection.processAddProducer(TransportConnection.java:479) > >>> at > >>> org.apache.activemq.command.ProducerInfo.visit(ProducerInfo.java:105) > >>> at > >>> > >>> > org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:292) > >>> at > >>> > >>> > org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:180) > >>> at > >>> > >>> > org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:68) > >>> at > >>> > >>> > org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:143) > >>> at > >>> > >>> > org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:206) > >>> at > >>> > >>> > org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:84) > >>> at > >>> > org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:196) > >>> at > >>> > org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:183) > >>> at java.lang.Thread.run(Thread.java:619) > >>> > >>> client side: > >>> > >>> Exception in thread "ActiveMQ Session Task" > >>> java.util.concurrent.RejectedExecutionException > >>> at > >>> > >>> > java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(Unknown > >>> Source) > >>> at java.util.concurrent.ThreadPoolExecutor.reject(Unknown > Source) > >>> at java.util.concurrent.ThreadPoolExecutor.execute(Unknown > >>> Source) > >>> at > >>> > >>> > org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:144) > >>> at > >>> > org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43) > >>> at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown > >>> Source) > >>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown > >>> Source) > >>> at java.lang.Thread.run(Unknown Source) > >>> > >>> > >>> Any idea? Thanks in advance! > >>> > >>> -- > >>> View this message in context: > >>> > http://www.nabble.com/having-problem-with-durable-subscription-tp17813954p17813954.html > >>> Sent from the ActiveMQ - User mailing list archive at Nabble.com. > >>> > >>> > >> > >> > > > > > > -- > View this message in context: > http://www.nabble.com/having-problem-with-durable-subscription-tp17813954p17828072.html > Sent from the ActiveMQ - User mailing list archive at Nabble.com. > > ------=_Part_6158_20218832.1213389217027--