0

I need to set message expiry for my message in a JMS Topic. I have tried by setting the properties of message.setJMSExpiration() and producer.getTimeToLive() methods. But I don't think so the messages which I posted still alive in Topic which I posted.

My doubt is whether these properties are used to discard the unsubscribed message from topic after the expiration time arrived? or after the message subscribed by a particular subscriber.

I have used selector to identify the particular client.

If any of the above property is not enough to make message expire then do I need any other configuration to make the message expire in producer side?

Am using Apache ActiveMQ 5.8.0 with JDK 1.6

Bhuvanesh Waran
  • 593
  • 12
  • 28

2 Answers2

0

My two cents of info. Hope this helps you to identify the problem you have.

There are two types of subscriptions, Durable and Non-durable subscription and subscribers (or applications that create subscriptions) are called Durable and Non-durable subscribers respectively.

Non-durable subscribers receive publications as long as the applications are running. Durable subscriptions receive publications even when the receiving applications are not running. Durable subscriptions are backed by storage (usually, queues) and messaging providers put the publications into the storage when applications are not running.

If there are no subscriptions for a topic, Messaging Provider will simply discard the publication.

Message Expiry (a.k.a TimeToLive ) is applicable to both types of subscriptions. If the subscriber application does not receive messages before the expiry, such messages expire and will not be delivered to receiving application.

Messages can only expire only after the producer publishes to Messaging Provider.

Shashi
  • 14,980
  • 2
  • 33
  • 52
  • Thanks for your answer. But this is the theory what I have gone through some articles over internet. As you said I have applied durable subscriptions only. Because my concern is my client do not miss any messages which is published by producer. My main concern is, when my client is not running for long span of time publisher has to expire the message, as the client is not running for logs time. In this context how do I tell publisher to make expire the message after this much of time if the subscriber not subscribe the message. – Bhuvanesh Waran Sep 03 '16 at 08:59
  • You are saying two things - (1) Client should not miss any message and (2) Message should expire after some time - Both contradicting each other. If you set expiry and client does not resume within expiry time, then client will miss that publication. In any case, at the publisher end you need to set the expiry time on the message before publishing it. Messaging provider will discard the message after the expiry time is over. – Shashi Sep 03 '16 at 14:07
  • In my concern, the client should not miss any messages until the message get expires only. Because of some security issues. Within the expiry time if the client started its subscription then no problem to get the message. So I try with by setting expiry time in publisher side. – Bhuvanesh Waran Sep 05 '16 at 02:33
0

1) Per the JMS spec, all QoS settings (persistence, expiry (aka TTL) and priority must be set on the Producer object. When set on the Message object, they are ignored.

2) Would need to see client code to validate the value of the TTL is set correctly.

3) TTL value is the time in milliseconds to expire the message (i.e. 300000 for 5 minutes), not the time from EPOCH.

Matt Pavlovich
  • 4,087
  • 1
  • 9
  • 17