I am designing a standalone application (no app servers) which is going to invoke two timers every 5 mins and send (based on whether files are present in a director) and receive messages from a queue. This application is planned to run for a long time (years) continuously....
Now i am having a dilema whether to create a JMS connection only once and use it all the time.. or to connect the connection every 5 mins and close them... (after doing business logics)
Any suggestion on the design will be helpful? If i go for single connection (and use JMS MessageListenr), what will happen if the queue manager is down and comes after one or two days.......
I tried a sample with ActiveMQ... and as soon as i killed active mq broker and producer ... the listener thread (which creates conn only once and using MessageListener) application automatically ends after few mins
// Listener code below
connectionFactory = new ActiveMQConnectionFactory(
ActiveMQConnection.DEFAULT_USER,
ActiveMQConnection.DEFAULT_PASSWORD,
ActiveMQConnection.DEFAULT_BROKER_URL);
connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
destination = session.createQueue("mmy first active mq queue");
MessageConsumer consumer = session.createConsumer(destination);
MyListener mylistener = new MyListener();
consumer.setMessageListener(mylistener);
connection.setExceptionListener(mylistener);