Return-Path: Delivered-To: apmail-geronimo-activemq-dev-archive@www.apache.org Received: (qmail 47249 invoked from network); 28 Nov 2006 01:51:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Nov 2006 01:51:57 -0000 Received: (qmail 52303 invoked by uid 500); 28 Nov 2006 01:52:06 -0000 Delivered-To: apmail-geronimo-activemq-dev-archive@geronimo.apache.org Received: (qmail 52287 invoked by uid 500); 28 Nov 2006 01:52:05 -0000 Mailing-List: contact activemq-dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-dev@geronimo.apache.org Received: (qmail 52278 invoked by uid 99); 28 Nov 2006 01:52:05 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Nov 2006 17:52:05 -0800 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 (herse.apache.org: domain of lists@nabble.com designates 72.21.53.35 as permitted sender) Received: from [72.21.53.35] (HELO talk.nabble.com) (72.21.53.35) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Nov 2006 17:51:52 -0800 Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1Gos8C-0001dN-3w for activemq-dev@geronimo.apache.org; Mon, 27 Nov 2006 17:51:32 -0800 Message-ID: <7571901.post@talk.nabble.com> Date: Mon, 27 Nov 2006 17:51:32 -0800 (PST) From: Sergey To: activemq-dev@geronimo.apache.org Subject: Re: Message Expiry In-Reply-To: <456A4DBF.4070404@exist.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: zeltynsh@gmail.com References: <6711322.post@talk.nabble.com> <452A1ED9.2010208@exist.com> <7539449.post@talk.nabble.com> <456A4DBF.4070404@exist.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi, I've tried your code. It worked. But then I substituted synch .receive() with asynch MessageListener, which I register after the same timeout. And surprise! The message arrives. But it still shouldn't, right? Let me post here my code: ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup( "ConnectionFactory" ); Connection connection = connectionFactory.createConnection( ); connection.start( ); long timeToLive = 1000; Session session = connection.createSession( false, Session.AUTO_ACKNOWLEDGE ); MessageProducer producer = session.createProducer( null ); producer.setTimeToLive( timeToLive ); Queue myQueue = session.createQueue( "TEST_QUEUE" ); Message m = session.createTextMessage( "message" ); producer.send( myQueue, m ); // sleeps a second longer than the expiration time. // Basically waits till queue expires. Thread.sleep( timeToLive + 1000 ); // myQueue should return null since it already expired MessageConsumer consumer = session.createConsumer( myQueue ); // Message msg = consumer.receive( 1000 ); // System.out.println( msg ); MessageListener messageListener = new MessageListener( ) { public void onMessage(Message m) { if ( m instanceof TextMessage ) { TextMessage textMessage = (TextMessage) m; try { System.out.println( "got messge: " + textMessage.getText( ) ); } catch ( JMSException e ) { e.printStackTrace( ); } } } }; consumer.setMessageListener( messageListener ); Regards, Sergey Z jlim wrote: > > > Hi, > > That's odd. I ran the same test case on 4.0.2 and I can't seem to > reproduced the problem. Would you mind posting a snippet of your code > so we could take a look at it? Btw, please make sure that the > setTimeToLive method is called before sending the message. You could > also try running the sample code below and see if it works for you > > ..... > connection.start(); > long timeToLive = 1000; > MessageProducer producer = session.createProducer(null); > p.setTimeToLive(timeToLive ); > Queue myQueue = session.createQueue("QUEUE"); > > Message m = session.createTextMessage("message"); > producer.send(myQueue, m); > // sleeps a second longer than the expiration time. > // Basically waits till queue expires. > Thread.sleep(timeToLive + 1000); > > //myQueue should return null since it already expired > MessageConsumer consumer = session.createConsumer(myQueue); > Message msg = consumer.receive(1000); > ...... > > > Regards, > Jonas > > > > > Sergey wrote: >> Hallo, >> >> I've got the same problem. Expiration dosn't seem to work. I'm using >> 4.0.2. >> >> >> >> jlim wrote: >> >>> Hi, >>> >>> Hmm - which version of ActiveMQ are you using? The message should have >>> expired and should not be consumed after the timetolive has elapsed. >>> >>> You can try looking on some of the test cases and see if you can >>> reproduce the issue: >>> >>> ie. >>> https://svn.apache.org/repos/asf/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsSendReceiveWithMessageExpirationTest.java >>> >>> btw, I tested this using trunk and appears to work ok :) >>> >>> >>> Regards, >>> Jonas >>> >>> >>> Christopher_Ong wrote: >>> >>>> I set the timetolive for a message as 1s and y after that period, the >>>> msg >>>> still remain there? Shouldn't be it wil automatically been deleted or >>>> send >>>> to dead msg queue? >>>> >>>> >>> >> >> > > -- View this message in context: http://www.nabble.com/Message-Expiry-tf2407730.html#a7571901 Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.