ARTEMIS-2559 Clear Transaction out of ResourceManager in case of failure

This commit is contained in:
Clebert Suconic 2019-11-22 10:30:29 -05:00
parent 6c33a48c15
commit 506c03a884
4 changed files with 15 additions and 0 deletions

View File

@ -392,12 +392,18 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
Transaction txToRollback = tx;
if (txToRollback != null) {
if (txToRollback.getXid() != null) {
resourceManager.removeTransaction(txToRollback.getXid());
}
txToRollback.rollbackIfPossible();
}
txToRollback = pendingTX;
if (txToRollback != null) {
if (txToRollback.getXid() != null) {
resourceManager.removeTransaction(txToRollback.getXid());
}
txToRollback.rollbackIfPossible();
}

View File

@ -46,4 +46,6 @@ public interface ResourceManager extends ActiveMQComponent {
List<Xid> getInDoubtTransactions();
int size();
}

View File

@ -61,6 +61,11 @@ public class ResourceManagerImpl implements ResourceManager {
// ActiveMQComponent implementation
@Override
public int size() {
return transactions.size();
}
@Override
public void start() throws Exception {
if (started) {

View File

@ -167,6 +167,8 @@ public class SessionFailureXATest extends ActiveMQTestBase {
Wait.assertEquals(0, () -> messagingService.getSessions().size());
Wait.assertEquals(0, messagingService.getResourceManager()::size);
locator = createInVMNonHALocator();
sessionFactory = createSessionFactory(locator);
clientSession = addClientSession(sessionFactory.createSession(true, false, false));