Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 47748 invoked from network); 6 Mar 2007 09:52:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Mar 2007 09:52:36 -0000 Received: (qmail 68210 invoked by uid 500); 6 Mar 2007 09:52:44 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 68016 invoked by uid 500); 6 Mar 2007 09:52:42 -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 68007 invoked by uid 99); 6 Mar 2007 09:52:42 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Mar 2007 01:52:42 -0800 X-ASF-Spam-Status: No, hits=0.3 required=10.0 tests=MAILTO_TO_SPAM_ADDR,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of james.strachan@gmail.com designates 64.233.182.191 as permitted sender) Received: from [64.233.182.191] (HELO nf-out-0910.google.com) (64.233.182.191) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Mar 2007 01:52:32 -0800 Received: by nf-out-0910.google.com with SMTP id y38so2410295nfb for ; Tue, 06 Mar 2007 01:52:11 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=kT4kwoBNuiLZqOVTIPMOnfnQd0h8gohZbO6w0Sg9VrECKpWA1UMEvH+QoTbkA6gc5WyjDVY5j50oNA0zfaqMInYQERnaqOyoymBPplDAI2sK5nwpdeajEwrm01bKCtoPwBzndLXG1ZAonTrT+Npw3a/ien1rp+69WYfHpNhXZuQ= 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=Il1WqpOkeYaNL8F8nXbZqljSSzxqlmu0H1eKqQ6ily7NM6q7hoZkoIF+n9mDuHd6oG41Mo6AIVIirljtEA1sVwxrwU732Q9CuwFAJ0MvRFCeMAR1O7i0Z/XPBBJA6LCqwxpg6ObSc1T3p+YOYx6G6EyhESyUENLs3Fd0H5Yi5dA= Received: by 10.78.171.13 with SMTP id t13mr763722hue.1173174730821; Tue, 06 Mar 2007 01:52:10 -0800 (PST) Received: by 10.78.155.11 with HTTP; Tue, 6 Mar 2007 01:52:10 -0800 (PST) Message-ID: Date: Tue, 6 Mar 2007 09:52:10 +0000 From: "James Strachan" To: users@activemq.apache.org Subject: Re: How to stop the program gracefully In-Reply-To: <9318656.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <9318656.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org FWIW there's no real need using a separate thread to create a consumer in it if you are using the MessageListener (async) approach. You only need to create separate threads if you are using the sync approach (consumer.receive*() stuff). Subscribing to messages lasts forever; so there is no explicit graceful shutdown. Maybe expose an MBean so folks can explicitly close things down - or listen to some queue/topic so folks can send your process a message to close down gracefully? On 3/5/07, LiXiao2007 wrote: > > I have a multi threaded program something like as follows. > > main() > { > create threads_1 to thread_n. > create a connection to JMS queue > for each thread > thread_i.start(); > } > > // for each thread's run method > run() > { > create session > create consumer > register the consumer with a message listener > } > > My understanding is that as soon as run finishes, the thread is gone but the > jms run time creates another thread listening on onMessage(). My question is > how to exit the program gracefully. I would like to let each thread finishes > its job and exits by itsself. > > Any help is greately appreciated. > > > > -- > View this message in context: http://www.nabble.com/How-to-stop-the-program-gracefully-tf3351123s2354.html#a9318656 > Sent from the ActiveMQ - User mailing list archive at Nabble.com. > > -- James ------- http://radio.weblogs.com/0112098/