Issue Details (XML | Word | Printable)

Key: SPR-5127
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Juergen Hoeller
Reporter: Joe Kearney
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring Framework

DMLC with cacheLevel=CACHE_CONNECTION and a non-JMS transaction manager causes the shared connection to be closed after the first transaction

Created: 29/Aug/08 11:54 AM   Updated: 04/Sep/08 04:20 AM   Resolved: 02/Sep/08 08:13 AM
Component/s: SpringJMS
Affects Version/s: 2.5.4
Fix Version/s: 2.5.6

Time Tracking:
Not Specified


 Description  « Hide

When the DMLC is used with a non-JMS transaction manager (for example DataSourceTransactionManager) then DMLC#doReceiveAndExecute() delegates to ConnectionFactoryUtils which binds the shared connection to the transaction and registers a synchronization to close it upon transaction completion. When the first transaction completes this synchronization runs and the shared connection is closed (there is no proxy or smart connection pattern used as in JDBC). Subsequent use of the now closed connection fail with IllegalStateException (as per JMS spec).

The bug appears to be in the ResourceFactory passed from DMLC to CFUtils. This implements createConnection() by returning a reference to the shared connection, however CFUtils is expecting a fresh connection that is can close (or at least one that suppresses close).

Using higher levels of caching avoids this issue since the DMLC never calls into CFUtils, it just uses the pre-established shared session.

We also notice that using a JmsTransactionManager causes the shared connection to be ignored, since a new connection is created and bound for each transaction.



Juergen Hoeller added a comment - 02/Sep/08 08:13 AM

Thanks for raising this! I've revised DMLC to correctly work with a non-JMS transaction manager and CACHE_CONNECTION level, not prematurely closing the shared Connection in that case. We simply expose a shared Connection proxy to the transaction synchronization code now, rather than the raw shared Connection.

This will be available in tonight's 2.5.6 snapshot (http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR). Please give it a try and let us know whether it works for you...

Juergen


Joe Kearney added a comment - 04/Sep/08 04:20 AM

Passes our test case using a non-JMS transaction manager, looks good. Still fails with a JMSTxMan since a new connection is created eagerly each transaction, but I suppose this is to be expected.

Thanks for such a quick turnaround on this, Juergen.

Joe