
Originally Posted by
Juergen Hoeller
The actual behavior depends on your JMS ConnectionFactory. JmsTemplate will fetch a Connection from the ConnectionFactory for each operation, putting the onus of Connection management onto the ConnectionFactory.
In a J2EE environment, the ConnectionFactory will usually return transactional Connections, i.e. the same Connection for an entire transaction. As a further example (unrelated to your use case), you could define Spring's SingleConnectionFactory, holding a single JMS Connection and exposing it to all ConnectionFactory callers.
In terms of reconnect behavior, concrete JMS providers will behave differently. If you're not happy with the raw behavior of your JMS provider / J2EE server, consider writing a ConnectionFactory proxy where you first check whether the Connection returned by the target ConnectionFactory is still valid, making sure to return an active Connection to the caller (i.e. JmsTemplate). This would be similar to how JDBC connection pools behave.
Juergen