I use solace as a JMS provider in my project. I use spring CachingConnectionFactory to retrieve Connection. On that connection I create new session. I have thread with one Consumer created on that session.
@Autowired
CachingConnectionFactory ccf;
Connection connection = ccf.createConnection();
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
MessageConsumer messageConsumer = new session.createConsumer(destination); // This is passed to new thread
I'm doing some failover tests. When I unplug server from network connection, it fails. When I connect server again I'm still receiving the same exception:
javax.jms.IllegalStateException: Error receiving message - already closed (Tried to call receive on a stopped message consumer.) ...
What is more CachingConnectionFactory has "reconnectOnException" property set to "true" by default (and I checked that is works).
Exception seems to be clear. So my question is: How to handle such case/exception when connection is lost and established again? Is it possible to have consumer alive again? Or I should create new consumer and new thread(what I would like to avoid)?