private void reinit() { final long startTime = System.currentTimeMillis(); synchronized (sessionMonitor) { close(); while (!isRunning.get()) { try { session = connection.createTopicSession(); publisher = session.createPublisher(session.createTopic(topic)); publisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT); publisher.setTimeToLive(config.getMessagesTTLMilliseconds()); isRunning.set(true); } catch (JMSException ex) { logger.debug(String.format("Got error while trying to get a session for topic %s", topic)); } } } final long secondsToRecreate = (System.currentTimeMillis() - startTime) / 1000; logger.info(String.format("Recreated topic [%s] in %d seconds", topic, secondsToRecreate)); }
pub.setTimeToLive(Message.DEFAULT_TIME_TO_LIVE);
publisher.setTimeToLive(timeToLive);
} else { TopicPublisher publisher = (TopicPublisher)pooledSession.producer(); publisher.setTimeToLive(ttl); publisher.publish((Topic)targetDestination, message, deliveryMode, priority, ttl);