JmsResourceHolder checks for nested DataSource transactions as well (for Oracle AQ compatibility)

Issue: SPR-11791
This commit is contained in:
Juergen Hoeller
2014-05-16 15:08:09 +02:00
parent 52f44b340e
commit 5faacd5a3d

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -191,10 +191,20 @@ public class JmsResourceHolder extends ResourceHolderSupport {
try { try {
Method getDataSourceMethod = this.connectionFactory.getClass().getMethod("getDataSource"); Method getDataSourceMethod = this.connectionFactory.getClass().getMethod("getDataSource");
Object ds = ReflectionUtils.invokeMethod(getDataSourceMethod, this.connectionFactory); Object ds = ReflectionUtils.invokeMethod(getDataSourceMethod, this.connectionFactory);
if (ds != null && TransactionSynchronizationManager.hasResource(ds)) { while (ds != null) {
// IllegalStateException from sharing the underlying JDBC Connection if (TransactionSynchronizationManager.hasResource(ds)) {
// which typically gets committed first, e.g. with Oracle AQ --> ignore // IllegalStateException from sharing the underlying JDBC Connection
return; // which typically gets committed first, e.g. with Oracle AQ --> ignore
return;
}
try {
// Check for decorated DataSource a la Spring's DelegatingDataSource
Method getTargetDataSourceMethod = ds.getClass().getMethod("getTargetDataSource");
ds = ReflectionUtils.invokeMethod(getTargetDataSourceMethod, ds);
}
catch (NoSuchMethodException nsme) {
ds = null;
}
} }
} }
catch (Throwable ex2) { catch (Throwable ex2) {