diff --git a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java index 38b1b1293ae94..c73a1cddb39ca 100644 --- a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java +++ b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java @@ -16,7 +16,6 @@ import com.arjuna.ats.arjuna.common.arjPropertyManager; import com.arjuna.ats.arjuna.coordinator.TransactionReaper; import com.arjuna.ats.arjuna.coordinator.TxControl; -import com.arjuna.ats.arjuna.recovery.RecoveryManager; import com.arjuna.ats.internal.arjuna.objectstore.jdbc.JDBCStore; import com.arjuna.ats.jta.common.JTAEnvironmentBean; import com.arjuna.ats.jta.common.jtaPropertyManager; @@ -158,7 +157,14 @@ public void startRecoveryService(final TransactionManagerConfiguration transacti public void handleShutdown(ShutdownContext context, TransactionManagerConfiguration transactions) { context.addLastShutdownTask(() -> { if (transactions.enableRecovery) { - RecoveryManager.manager().terminate(true); + try { + QuarkusRecoveryService.getInstance().stop(); + } catch (Exception e) { + // the recovery manager throws IllegalStateException if it has already been shutdown + log.warn("The recovery manager has already been shutdown", e); + } finally { + QuarkusRecoveryService.getInstance().destroy(); + } } TransactionReaper.terminate(false); }); diff --git a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/QuarkusRecoveryService.java b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/QuarkusRecoveryService.java index 55ff7ae05fe22..923bcfe4625a1 100644 --- a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/QuarkusRecoveryService.java +++ b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/QuarkusRecoveryService.java @@ -51,4 +51,11 @@ public void create() { } xaResources.clear(); } + + @Override + public void destroy() { + super.destroy(); + isCreated = false; + recoveryManagerService = null; + } }