Hi All, I have an application which uses JMS to publish/subscribe to messages. I am having a hard time finding resources regarding explanations of using the publish method of the javax.jms.TopicPublisher class. I have googled it and found countless examples, but cannot find anywhere that explains the meaning of the method arguments DeliveryMode and timeToLive. Here is what I was able to find online :
public void publish( Topic topic, Message message, int deliveryMode, int priority, long timeToLive) throws JMSExceptionYou must provide a message. You may also specify the topic name, delivery mode (DeliveryMode.PERSISTENT or DeliveryMode.NON_PERSISTENT), priority (0-9), and time-to-live (in milliseconds). If not specified, the delivery mode, priority, and time-to-live attributes are set to one of the following:
What I can't seem to find is what the differance between persistant and notn persistant delivery modes are, and what time-to-live means. The reason I am asking, is that I am publishing a lot of messages and some are getting lost. I think I need to tweak something, maybe if the system is busy and I increase my time-to-live time, the message listener will have more time to recieve it?
In a publish subscribe mechanism if the subscriber is not alive the messages gets thrown away. This is true even if you set to delivery mode PERSISTENT. The delivery mode persistent just means that in the event of a server crash the messages can be recovered and delivered to the subscribers connecting back.
I hope time to live parameter is to how long the server to keep a message if a subscriber is not alive before throwing it away
Thank you very much for your reply. I am wondering what would cause a message to not make it to the subscriber. I have log messages in my publisher and my subscriber. I can see that all messages are getting published, but only some are getting to the onMessage method of my subscriber. Not sure what to look for, any ideas? Thanks so much again for your reply.
I don't know what JMS server you are using .. some time these serves have something called selectors. In a selector configuration if the selector on the topic does not match with the eslected property in the message .. the message gets thrown way ?.. do you have something like that