if i set the TimeToLive in my Producer, my Subscriber doesn't receive any message. I use an activeMQ V. 5.13.3 as message broker.
My Producer
javax.naming.Context ctx = new InitialContext();
// lookup the connection factory
factory = (javax.jms.TopicConnectionFactory)ctx.lookup("ConnectionFactory");
// create a new TopicConnection for pub/sub messaging
connection = factory.createConnection("user", "pwd");
// lookup an existing topic
destination = (javax.jms.Topic)ctx.lookup("MyTopic");
// create a new TopicSession for the client
session = connection.createSession(false, TopicSession.AUTO_ACKNOWLEDGE);
connection.start();
producer = session.createProducer(destination);
producer.setTimeToLive(10000);
TextMessage message = session.createTextMessage();
message.setText("The Message");
producer.send(message);
My Consumer
javax.naming.Context ctx = new InitialContext();
// lookup the connection factory
factory = (javax.jms.TopicConnectionFactory)ctx.lookup("ConnectionFactory");
// create a new TopicConnection for pub/sub messaging
connection = factory.createConnection("user", "pwd");
connection.setClientID("ClientID-"+id);
connection.start();
// lookup an existing topic
destination = (javax.jms.Topic)ctx.lookup("MyTopic");
// create a new TopicSession for the client
session = connection.createSession(false, TopicSession.AUTO_ACKNOWLEDGE);
consumer = session.createDurableSubscriber(destination, id);
consumer.setMessageListener(new MessageListenerConsumer("ClientID-"+id));
If i doesn't use setTimeToLive() the consumer receive the message but with setTTL() no message arrive's the consumer - not less or more as the defined 10 seconds TTL! Why? Where is the mistake?
Thx
Could be that your client's and server's system clocks are out of sync.