You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "Suchitha Koneru (sukoneru)" <su...@cisco.com> on 2007/07/18 04:10:39 UTC

messages are received after expiry time

Hello Active MQ users , 
                               The active mq version which we use is
4.0.2. Our application uses durable subscriber and topic publishers. The
time to live on the topic publishers is set as 5 minutes which 300,000
seconds. 
Two  durable subscribers a and b  are created and started  10 minutes
after the messages are published. Both the subscribers receive all the
messages. The messages should expire after 5 minutes , how come they are
still getting delivered ??  Please let me know, if Iam missing anything
in teh configuration. The broker is started at command line from active
me's bin directory.
 
thanks,
suchitha.
 
The code for publisher  is as follows 
InitialContext envContext = new InitialContext(prop);

connectionFactory = new
ActiveMQConnectionFactory("tcp://171.69.155.137:61616"); 

connection = (TopicConnection )connectionFactory.createConnection();

session = ( TopicSession) connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);

topic = (Topic) envContext.lookup("MyTopic") ;

producer = (TopicPublisher)session.createPublisher(topic);

if(producer != null){

producer.setTimeToLive(300000); // time to live 5 minutes

producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

connection.start();

}

int i=0 ;

while(i<10){

System.out.println("sending message");

ObjectMessage objMsg = session.createObjectMessage(i+"");

System.out.println("publishing the message");

i++;

producer.publish(objMsg);

}

 
code for receiver 
 
InitialContext envContext = new InitialContext(prop);

connectionFactory = new
ActiveMQConnectionFactory("tcp://171.69.155.137:61616"); 

connection = (TopicConnection )connectionFactory.createConnection();

connection.setClientID(clientID);

session = ( TopicSession) connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);

topic = (Topic) envContext.lookup("MyTopic") ;

durableSubscriber = session.createDurableSubscriber(topic,
durableSubscriptionName);

durableSubscriber.setMessageListener(this);

if(durableSubscriber != null){

connection.start(); 

System.out.println("receiver started");

}

public void onMessage(Message message){

 

if(message instanceof ObjectMessage) {

ObjectMessage objMessage = (ObjectMessage) message;

System.out.println(this.durableSubscriptionName+"
"+objMessage.getObject().toString() );

}

}

 

Re: messages are received after expiry time

Posted by Rob Davies <ra...@gmail.com>.
this is fixed - http://issues.apache.org/activemq/browse/AMQ-1056 I  
guess it was fixed after the 4.1.1 release was cut  :(
On Jul 18, 2007, at 4:39 PM, ttmdev wrote:

>
> I have tried this on 4.1.1 and I'm getting the same results as  
> Suchitha. I
> dumped the timestamp and expiration header fields on receipt and  
> they appear
> to be set properly. The expiration is equal to timestamp 
> +timetolive_value
>
> The JMS specification states the following:
>
> "Clients should not receive messages that have expired; however,  
> JMS does
> not guarantee that this will not happen."
>
> I hate double-negatives :(
>
> So I guess it is up to the client to rely on getJMSTimestamp() and
> getJMSExpiration to do the math and determine whether to discard the
> message?
>
> Joe
>
>
> rajdavies wrote:
>>
>> Can I suggest you use the 4.1.1 release ?  http:// 
>> activemq.apache.org/
>> activemq-411-release.html
>>
>> cheers,
>>
>> Rob
>>
>> On Jul 18, 2007, at 3:10 AM, Suchitha Koneru ((sukoneru)) wrote:
>>
>>> Hello Active MQ users ,
>>>                                The active mq version which we use is
>>> 4.0.2. Our application uses durable subscriber and topic
>>> publishers. The
>>> time to live on the topic publishers is set as 5 minutes which  
>>> 300,000
>>> seconds.
>>> Two  durable subscribers a and b  are created and started  10  
>>> minutes
>>> after the messages are published. Both the subscribers receive  
>>> all the
>>> messages. The messages should expire after 5 minutes , how come
>>> they are
>>> still getting delivered ??  Please let me know, if Iam missing
>>> anything
>>> in teh configuration. The broker is started at command line from
>>> active
>>> me's bin directory.
>>>
>>> thanks,
>>> suchitha.
>>>
>>> The code for publisher  is as follows
>>> InitialContext envContext = new InitialContext(prop);
>>>
>>> connectionFactory = new
>>> ActiveMQConnectionFactory("tcp://171.69.155.137:61616");
>>>
>>> connection = (TopicConnection )connectionFactory.createConnection();
>>>
>>> session = ( TopicSession) connection.createSession(false,
>>> Session.AUTO_ACKNOWLEDGE);
>>>
>>> topic = (Topic) envContext.lookup("MyTopic") ;
>>>
>>> producer = (TopicPublisher)session.createPublisher(topic);
>>>
>>> if(producer != null){
>>>
>>> producer.setTimeToLive(300000); // time to live 5 minutes
>>>
>>> producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>>>
>>> connection.start();
>>>
>>> }
>>>
>>> int i=0 ;
>>>
>>> while(i<10){
>>>
>>> System.out.println("sending message");
>>>
>>> ObjectMessage objMsg = session.createObjectMessage(i+"");
>>>
>>> System.out.println("publishing the message");
>>>
>>> i++;
>>>
>>> producer.publish(objMsg);
>>>
>>> }
>>>
>>>
>>> code for receiver
>>>
>>> InitialContext envContext = new InitialContext(prop);
>>>
>>> connectionFactory = new
>>> ActiveMQConnectionFactory("tcp://171.69.155.137:61616");
>>>
>>> connection = (TopicConnection )connectionFactory.createConnection();
>>>
>>> connection.setClientID(clientID);
>>>
>>> session = ( TopicSession) connection.createSession(false,
>>> Session.AUTO_ACKNOWLEDGE);
>>>
>>> topic = (Topic) envContext.lookup("MyTopic") ;
>>>
>>> durableSubscriber = session.createDurableSubscriber(topic,
>>> durableSubscriptionName);
>>>
>>> durableSubscriber.setMessageListener(this);
>>>
>>> if(durableSubscriber != null){
>>>
>>> connection.start();
>>>
>>> System.out.println("receiver started");
>>>
>>> }
>>>
>>> public void onMessage(Message message){
>>>
>>>
>>>
>>> if(message instanceof ObjectMessage) {
>>>
>>> ObjectMessage objMessage = (ObjectMessage) message;
>>>
>>> System.out.println(this.durableSubscriptionName+"
>>> "+objMessage.getObject().toString() );
>>>
>>> }
>>>
>>> }
>>>
>>>
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/messages-are- 
> received--after-expiry-time-tf4100648s2354.html#a11670636
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


Re: messages are received after expiry time

Posted by ttmdev <jo...@ttmsolutions.com>.
I have tried this on 4.1.1 and I'm getting the same results as Suchitha. I
dumped the timestamp and expiration header fields on receipt and they appear
to be set properly. The expiration is equal to timestamp+timetolive_value

The JMS specification states the following:

"Clients should not receive messages that have expired; however, JMS does
not guarantee that this will not happen." 

I hate double-negatives :(

So I guess it is up to the client to rely on getJMSTimestamp() and
getJMSExpiration to do the math and determine whether to discard the
message? 

Joe 


rajdavies wrote:
> 
> Can I suggest you use the 4.1.1 release ?  http://activemq.apache.org/ 
> activemq-411-release.html
> 
> cheers,
> 
> Rob
> 
> On Jul 18, 2007, at 3:10 AM, Suchitha Koneru ((sukoneru)) wrote:
> 
>> Hello Active MQ users ,
>>                                The active mq version which we use is
>> 4.0.2. Our application uses durable subscriber and topic  
>> publishers. The
>> time to live on the topic publishers is set as 5 minutes which 300,000
>> seconds.
>> Two  durable subscribers a and b  are created and started  10 minutes
>> after the messages are published. Both the subscribers receive all the
>> messages. The messages should expire after 5 minutes , how come  
>> they are
>> still getting delivered ??  Please let me know, if Iam missing  
>> anything
>> in teh configuration. The broker is started at command line from  
>> active
>> me's bin directory.
>>
>> thanks,
>> suchitha.
>>
>> The code for publisher  is as follows
>> InitialContext envContext = new InitialContext(prop);
>>
>> connectionFactory = new
>> ActiveMQConnectionFactory("tcp://171.69.155.137:61616");
>>
>> connection = (TopicConnection )connectionFactory.createConnection();
>>
>> session = ( TopicSession) connection.createSession(false,
>> Session.AUTO_ACKNOWLEDGE);
>>
>> topic = (Topic) envContext.lookup("MyTopic") ;
>>
>> producer = (TopicPublisher)session.createPublisher(topic);
>>
>> if(producer != null){
>>
>> producer.setTimeToLive(300000); // time to live 5 minutes
>>
>> producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>>
>> connection.start();
>>
>> }
>>
>> int i=0 ;
>>
>> while(i<10){
>>
>> System.out.println("sending message");
>>
>> ObjectMessage objMsg = session.createObjectMessage(i+"");
>>
>> System.out.println("publishing the message");
>>
>> i++;
>>
>> producer.publish(objMsg);
>>
>> }
>>
>>
>> code for receiver
>>
>> InitialContext envContext = new InitialContext(prop);
>>
>> connectionFactory = new
>> ActiveMQConnectionFactory("tcp://171.69.155.137:61616");
>>
>> connection = (TopicConnection )connectionFactory.createConnection();
>>
>> connection.setClientID(clientID);
>>
>> session = ( TopicSession) connection.createSession(false,
>> Session.AUTO_ACKNOWLEDGE);
>>
>> topic = (Topic) envContext.lookup("MyTopic") ;
>>
>> durableSubscriber = session.createDurableSubscriber(topic,
>> durableSubscriptionName);
>>
>> durableSubscriber.setMessageListener(this);
>>
>> if(durableSubscriber != null){
>>
>> connection.start();
>>
>> System.out.println("receiver started");
>>
>> }
>>
>> public void onMessage(Message message){
>>
>>
>>
>> if(message instanceof ObjectMessage) {
>>
>> ObjectMessage objMessage = (ObjectMessage) message;
>>
>> System.out.println(this.durableSubscriptionName+"
>> "+objMessage.getObject().toString() );
>>
>> }
>>
>> }
>>
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/messages-are-received--after-expiry-time-tf4100648s2354.html#a11670636
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: messages are received after expiry time

Posted by Rob Davies <ra...@gmail.com>.
Can I suggest you use the 4.1.1 release ?  http://activemq.apache.org/ 
activemq-411-release.html

cheers,

Rob

On Jul 18, 2007, at 3:10 AM, Suchitha Koneru ((sukoneru)) wrote:

> Hello Active MQ users ,
>                                The active mq version which we use is
> 4.0.2. Our application uses durable subscriber and topic  
> publishers. The
> time to live on the topic publishers is set as 5 minutes which 300,000
> seconds.
> Two  durable subscribers a and b  are created and started  10 minutes
> after the messages are published. Both the subscribers receive all the
> messages. The messages should expire after 5 minutes , how come  
> they are
> still getting delivered ??  Please let me know, if Iam missing  
> anything
> in teh configuration. The broker is started at command line from  
> active
> me's bin directory.
>
> thanks,
> suchitha.
>
> The code for publisher  is as follows
> InitialContext envContext = new InitialContext(prop);
>
> connectionFactory = new
> ActiveMQConnectionFactory("tcp://171.69.155.137:61616");
>
> connection = (TopicConnection )connectionFactory.createConnection();
>
> session = ( TopicSession) connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
>
> topic = (Topic) envContext.lookup("MyTopic") ;
>
> producer = (TopicPublisher)session.createPublisher(topic);
>
> if(producer != null){
>
> producer.setTimeToLive(300000); // time to live 5 minutes
>
> producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>
> connection.start();
>
> }
>
> int i=0 ;
>
> while(i<10){
>
> System.out.println("sending message");
>
> ObjectMessage objMsg = session.createObjectMessage(i+"");
>
> System.out.println("publishing the message");
>
> i++;
>
> producer.publish(objMsg);
>
> }
>
>
> code for receiver
>
> InitialContext envContext = new InitialContext(prop);
>
> connectionFactory = new
> ActiveMQConnectionFactory("tcp://171.69.155.137:61616");
>
> connection = (TopicConnection )connectionFactory.createConnection();
>
> connection.setClientID(clientID);
>
> session = ( TopicSession) connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
>
> topic = (Topic) envContext.lookup("MyTopic") ;
>
> durableSubscriber = session.createDurableSubscriber(topic,
> durableSubscriptionName);
>
> durableSubscriber.setMessageListener(this);
>
> if(durableSubscriber != null){
>
> connection.start();
>
> System.out.println("receiver started");
>
> }
>
> public void onMessage(Message message){
>
>
>
> if(message instanceof ObjectMessage) {
>
> ObjectMessage objMessage = (ObjectMessage) message;
>
> System.out.println(this.durableSubscriptionName+"
> "+objMessage.getObject().toString() );
>
> }
>
> }
>
>