Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 46853 invoked from network); 28 Nov 2009 21:10:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Nov 2009 21:10:36 -0000 Received: (qmail 22620 invoked by uid 500); 28 Nov 2009 21:10:35 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 22541 invoked by uid 500); 28 Nov 2009 21:10:35 -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 22529 invoked by uid 99); 28 Nov 2009 21:10:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Nov 2009 21:10:35 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Nov 2009 21:10:25 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1NEUYO-0003od-WE for users@activemq.apache.org; Sat, 28 Nov 2009 13:10:05 -0800 Message-ID: <26556997.post@talk.nabble.com> Date: Sat, 28 Nov 2009 13:10:04 -0800 (PST) From: jaguarg To: users@activemq.apache.org Subject: Re: How to publish only if active subscribers? In-Reply-To: <26545404.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: fotshudi@gmail.com References: <26545404.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi, I came across this http://activemq.apache.org/advisory-message.html I guess advisory message could be used. any practical example? Thanks -- jaguarg jaguarg wrote: > > Hi, > I would like to implement a feature where I only publish on a specific > topic if there is one or more subscribers listening on for this topic? > This is my sample code: > ActiveMQConnectionFactory factory = new > ActiveMQConnectionFactory("tcp://:61616"); > connection = factory.createConnection(); > session = connection.createSession(false, > Session.AUTO_ACKNOWLEDGE); > ... > > Topic topic = session.createTopic(); > MessageProducer publisher = session.createProducer(topic); > publisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT); > publisher.send(session.createTextMessage(); > > How do I avoid pushing this data if there are not subscriber? > > Thanks > > -- > jaguarg > -- View this message in context: http://old.nabble.com/How-to-publish-only-if-active-subscribers--tp26545404p26556997.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.