Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 49377 invoked from network); 7 Feb 2007 08:34:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Feb 2007 08:34:53 -0000 Received: (qmail 76577 invoked by uid 500); 7 Feb 2007 08:34:59 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 76557 invoked by uid 500); 7 Feb 2007 08:34:59 -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 76548 invoked by uid 99); 7 Feb 2007 08:34:59 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Feb 2007 00:34:59 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of james.strachan@gmail.com designates 66.249.92.173 as permitted sender) Received: from [66.249.92.173] (HELO ug-out-1314.google.com) (66.249.92.173) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Feb 2007 00:34:49 -0800 Received: by ug-out-1314.google.com with SMTP id m3so124161ugc for ; Wed, 07 Feb 2007 00:34:24 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=TZ0lzwpM/hDc68rAviyAN4OSTKjIQDlMiqLnp5nj5hCwhQzKwuDbtJ+QFVuancBJYBhMq31FQIpi74sJ5U3sq3sSR00TF2Gfo6g0MNihiUdWt7VaPa1jNiAW95vbusJug5RIMserdOOLB+NYed6mec2TvCQfYBh3P6ZhFzgv3ig= Received: by 10.78.142.14 with SMTP id p14mr181831hud.1170837254097; Wed, 07 Feb 2007 00:34:14 -0800 (PST) Received: by 10.78.155.11 with HTTP; Wed, 7 Feb 2007 00:34:14 -0800 (PST) Message-ID: Date: Wed, 7 Feb 2007 08:34:14 +0000 From: "James Strachan" To: users@activemq.apache.org Subject: Re: durable subscriptions In-Reply-To: <5BD9FA70F5EDAC43AB816A5FDE30F6AC0392DB16@xmb-sjc-21a.amer.cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <5BD9FA70F5EDAC43AB816A5FDE30F6AC0392DB16@xmb-sjc-21a.amer.cisco.com> X-Virus-Checked: Checked by ClamAV on apache.org On 2/6/07, Suchitha Koneru (sukoneru) wrote: > Thank you so much James. > Which version of active mq support durable subscriptions, All of them since 1.0 > As of now, I am using the following jars , in regard to active mq > > activemq-core-4.0.1.jar > backport-util-concurrent-2.1.jar > geronimo-j2ee-management_1.0_spec-1.0.jar > geronimo-jms_1.1_spec-1.0.jar > incubator-activemq-4.0.2.jar > > > Please let me know, if I am understanding it correctly. > 1) First approach > Configuring durable subscriptions on the ActiveMQConnectionFactory > object. > In the conf/context.xml , I'll add the clientID as follows > > auth="Container" > > type="org.apache.activemq.ActiveMQConnectionFactory" > description="JMS Connection Factory" > factory="org.apache.activemq.jndi.JNDIReferenceFactory" > brokerURL="tcp://localhost:61616" > brokerName="LocalActiveMQBroker" > clientID = "CMD" > /> > > 2) Second Approach > The code that creates the Connection can specify the ClientID > before calling start(); > > Ictx = new javax.naming.InitialContext(); > envContext = (Context)Ictx.lookup("java:comp/env"); > //lookup the connection factory > javax.jms.TopicConnectionFactory factory = > (javax.jms.TopicConnectionFactory)envContext.lookup("jms/ConnectionFacto > ry"); > HerbieConnection = factory.createTopicConnection(); > HerbieConnection.setClientID("CMD"); > HerbieConnection.start(); Yes - either of those is fine. Also remember to use the right JMS API to create a durable subscriber, giving a unique subscriber name too http://java.sun.com/j2ee/1.4/docs/api/javax/jms/Session.html#createDurableSubscriber(javax.jms.Topic,%20java.lang.String) Its the combination of clientID and subscriber name which identify the durable subscription. (And the JMS spec insists that clientID must be globally unique - an attempt to create 2 connections with the same ID will cause the 2nd connection attempt to fail) -- James ------- http://radio.weblogs.com/0112098/