You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by pbolle <bo...@productandconcept.com> on 2007/07/04 17:42:47 UTC

problem set the expiration time for durable topic messages

Hi ActiveMQ users,

In my project I use a durable topic to distribute events. The only problem I
have is to set the expiration time. I am not sure if I put an error into my
program or found an activeMQ but I published the message with the following
code:
publisher:
connection = factory.createConnection();    	
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = session.createTopic("topic.article.messages");

ObjectMessage message = session.createObjectMessage(baseArticle);
message.setJMSExpiration(System.currentTimeMillis() + JMS_TIMEOUT);
message.setStringProperty("articleId", baseArticle.getArticleId());
publisher.send(message);

subscriber:
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url);
connection = factory.createConnection();
connection.setClientID(subscriberId);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = session.createTopic(JMS_TOPIC);
MessageConsumer consumer = session.createDurableSubscriber(topic,
subscriberId);
consumer.setMessageListener(this);
connection.start();

any help is welcome
Regards Philipp 

-- 
View this message in context: http://www.nabble.com/problem-set-the-expiration-time-for-durable-topic-messages-tf4025141s2354.html#a11433150
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: problem set the expiration time for durable topic messages

Posted by ferry97 <vr...@yahoo.com>.
Thanks, I tried it, and it works (in ActiveMQ5 SNAPSHOT, as mentioned in JIRA
ActiveMQ 4.1.1 has bug regarding handling expired message).
BTW, does the expired message persist ? or it can be configured ? How to
access the expired message?
-- 
View this message in context: http://www.nabble.com/problem-set-the-expiration-time-for-durable-topic-messages-tf4025141s2354.html#a12304911
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: problem set the expiration time for durable topic messages

Posted by Rob Davies <ra...@gmail.com>.
set time to live on the message producer ...

On Aug 23, 2007, at 5:28 AM, ferry97 wrote:

>
> Hi,
> So should we use Message.setJMSExpiration or Producer.setTimeToLive ?
> Thanks.
> Regards,
> Ferry
>
>
> pbolle wrote:
>>
>> Hi,
>>
>> Sorry, my last comment was not correct. In the trunk version I  
>> have the
>> problem that all messages never reach the subscriber. Now I  
>> corrected my
>> unit test and I have another problem.
>>
>> The new trunk version now has a new problem. It is not possible to  
>> delete
>> a durable subscriber via mbean.
>>
>> I have built some tests that simulate most of my use cases. If I  
>> have some
>> junit tests, what is the best way to submit these tests?
>>
>> If somebody would give me a hint how to change my tests that fits to
>> ActiveMQ guidelines, I would improve my test.
>>
>> I would be pleased to hearing from you soon.
>>
>> Thanks in advanced.
>>
>> Best regards Philipp
>> By the way I attached the test. The test fails in testTimeOut with  
>> the
>> trunk version and in some other places with the 4.1.1
>>
>>
>> Suchitha Koneru (sukoneru) wrote:
>>>
>>> Hello Philipp,
>>> Thank you for the update. What is the SVN version ? Could you please
>>> clarify
>>>
>>  http://www.nabble.com/file/p11770854/TopicTest.java TopicTest.java
>>
>
> -- 
> View this message in context: http://www.nabble.com/problem-set-the- 
> expiration-time-for-durable-topic-messages- 
> tf4025141s2354.html#a12287390
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


RE: problem set the expiration time for durable topic messages

Posted by ferry97 <vr...@yahoo.com>.
Hi,
So should we use Message.setJMSExpiration or Producer.setTimeToLive ?
Thanks.
Regards,
Ferry


pbolle wrote:
> 
> Hi,
> 
> Sorry, my last comment was not correct. In the trunk version I have the
> problem that all messages never reach the subscriber. Now I corrected my
> unit test and I have another problem.
> 
> The new trunk version now has a new problem. It is not possible to delete
> a durable subscriber via mbean.
> 
> I have built some tests that simulate most of my use cases. If I have some
> junit tests, what is the best way to submit these tests?
> 
> If somebody would give me a hint how to change my tests that fits to
> ActiveMQ guidelines, I would improve my test.
> 
> I would be pleased to hearing from you soon.
> 
> Thanks in advanced.
> 
> Best regards Philipp
> By the way I attached the test. The test fails in testTimeOut with the
> trunk version and in some other places with the 4.1.1
> 
> 
> Suchitha Koneru (sukoneru) wrote:
>> 
>> Hello Philipp,
>> Thank you for the update. What is the SVN version ? Could you please
>> clarify 
>> 
>  http://www.nabble.com/file/p11770854/TopicTest.java TopicTest.java 
> 

-- 
View this message in context: http://www.nabble.com/problem-set-the-expiration-time-for-durable-topic-messages-tf4025141s2354.html#a12287390
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


RE: problem set the expiration time for durable topic messages

Posted by pbolle <bo...@productandconcept.com>.
Hi,

Sorry, my last comment was not correct. In the trunk version I have the
problem that all messages never reach the subscriber. Now I corrected my
unit test and I have another problem.

The new trunk version now has a new problem. It is not possible to delete a
durable subscriber via mbean.

I have built some tests that simulate most of my use cases. If I have some
junit tests, what is the best way to submit these tests?

If somebody would give me a hint how to change my tests that fits to
ActiveMQ guidelines, I would improve my test.

I would be pleased to hearing from you soon.

Thanks in advanced.

Best regards Philipp
By the way I attached the test. The test fails in testTimeOut with the trunk
version and in some other places with the 4.1.1


Suchitha Koneru (sukoneru) wrote:
> 
> Hello Philipp,
> Thank you for the update. What is the SVN version ? Could you please
> clarify 
> 
http://www.nabble.com/file/p11770854/TopicTest.java TopicTest.java 
-- 
View this message in context: http://www.nabble.com/problem-set-the-expiration-time-for-durable-topic-messages-tf4025141s2354.html#a11770854
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


RE: problem set the expiration time for durable topic messages

Posted by "Suchitha Koneru (sukoneru)" <su...@cisco.com>.
Hello Philipp,
Thank you for the update. What is the SVN version ? Could you please
clarify 

Suchitha. 

-----Original Message-----
From: pbolle [mailto:bolle@productandconcept.com] 
Sent: Tuesday, July 24, 2007 1:10 AM
To: users@activemq.apache.org
Subject: Re: problem set the expiration time for durable topic messages


I found the problem!
The problem is that there is bug in the Version apache-activemq-4.1.1.
But the SVN version is working correct.

Regards Philipp


rajdavies wrote:
> 
> You don't set the expiration directly on the message - but set the 
> time-to-live on the Producer - i.e.
> javax.jms.MessageProducer.setTimeToLive(long timeToLive)
> 

--
View this message in context:
http://www.nabble.com/problem-set-the-expiration-time-for-durable-topic-
messages-tf4025141s2354.html#a11758634
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: problem set the expiration time for durable topic messages

Posted by pbolle <bo...@productandconcept.com>.
I found the problem!
The problem is that there is bug in the Version apache-activemq-4.1.1. But
the SVN version is working correct.

Regards Philipp


rajdavies wrote:
> 
> You don't set the expiration directly on the message - but set the  
> time-to-live on the Producer - i.e.  
> javax.jms.MessageProducer.setTimeToLive(long timeToLive)
> 

-- 
View this message in context: http://www.nabble.com/problem-set-the-expiration-time-for-durable-topic-messages-tf4025141s2354.html#a11758634
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: problem set the expiration time for durable topic messages

Posted by pbolle <bo...@productandconcept.com>.
Thank you very much for your fast response. I changed my code but I still
have the problem that time-to-live has no effect.

It here a unittest that test nearly the same situation. Then I could find
out if this is a problem of my program or bug in ActiveMQ.

Regards Philipp


rajdavies wrote:
> 
> You don't set the expiration directly on the message - but set the  
> time-to-live on the Producer - i.e.  
> javax.jms.MessageProducer.setTimeToLive(long timeToLive)
> 

-- 
View this message in context: http://www.nabble.com/problem-set-the-expiration-time-for-durable-topic-messages-tf4025141s2354.html#a11459193
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: problem set the expiration time for durable topic messages

Posted by Rob Davies <ra...@gmail.com>.
You don't set the expiration directly on the message - but set the  
time-to-live on the Producer - i.e.  
javax.jms.MessageProducer.setTimeToLive(long timeToLive)

On Jul 4, 2007, at 4:42 PM, pbolle wrote:

>
> Hi ActiveMQ users,
>
> In my project I use a durable topic to distribute events. The only  
> problem I
> have is to set the expiration time. I am not sure if I put an error  
> into my
> program or found an activeMQ but I published the message with the  
> following
> code:
> publisher:
> connection = factory.createConnection();    	
> Session session = connection.createSession(false,  
> Session.AUTO_ACKNOWLEDGE);
> Topic topic = session.createTopic("topic.article.messages");
>
> ObjectMessage message = session.createObjectMessage(baseArticle);
> message.setJMSExpiration(System.currentTimeMillis() + JMS_TIMEOUT);
> message.setStringProperty("articleId", baseArticle.getArticleId());
> publisher.send(message);
>
> subscriber:
> ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory 
> (url);
> connection = factory.createConnection();
> connection.setClientID(subscriberId);
> Session session = connection.createSession(false,  
> Session.AUTO_ACKNOWLEDGE);
> Topic topic = session.createTopic(JMS_TOPIC);
> MessageConsumer consumer = session.createDurableSubscriber(topic,
> subscriberId);
> consumer.setMessageListener(this);
> connection.start();
>
> any help is welcome
> Regards Philipp
>
> -- 
> View this message in context: http://www.nabble.com/problem-set-the- 
> expiration-time-for-durable-topic-messages- 
> tf4025141s2354.html#a11433150
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>