activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonas Lim <j...@exist.com>
Subject Re: Message Expiry
Date Mon, 27 Nov 2006 02:30:23 GMT

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?
>>>   
>>>       
>>     
>
>   

Mime
View raw message