Re: Message Expiry

2006-11-27 Thread Sergey

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.



Re: Message Expiry

2006-11-27 Thread Jonas Lim


hi Sergey,

This does look like a bug.  You can monitor the progress of this issue 
at  https://issues.apache.org/activemq/browse/AMQ-1072.


Regards,
Jonas

Sergey wrote:

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?
  
  
  


  
  



  


Re: Message Expiry

2006-11-25 Thread Sergey

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#a7539449
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.



Re: Message Expiry

2006-11-25 Thread James Strachan

On 11/25/06, Sergey [EMAIL PROTECTED] wrote:


Hallo,

I've got the same problem. Expiration dosn't seem to work. I'm using 4.0.2.


Have you tried trunk or 4.1?

--

James
---
http://radio.weblogs.com/0112098/