1 2 Previous Next 17 Replies Latest reply on Feb 24, 2016 8:59 AM by Thomas Jenkinson

    How to enlist a custom XAResouce in the spring and start the recovery manager service

    Zheng Feng Expert



      I currently use the following codes to enlist the custom XAResouce explictly


      public class ExampleService {
          private JdbcTemplate jdbc;
          private JtaTransactionManager transactionManager;
          public ExampleService(JdbcTemplate jdbc) {
              this.jdbc = jdbc;
          public void testRecovery() throws Exception {
              Transaction transaction  = transactionManager.getTransactionManager().getTransaction();
              transaction.enlistResource(new DummyXAResource(DummyXAResource.faultType.HALT));
              jdbc.execute("insert into example values (1, 'test1')");


      I wonder that is there the way to inject the bean of DummyXAResouce and the spring can enlist it in the method with the annotation of Transactional automatically ?


      in term of starting the recovery manager service, it looks like the spring does not provide the way to integrate the recovery manager. So it need to setup and run the scanning manually in the application.

      I borrow some codes from the ArjunaJTA/recovery and it should work.

          if(args.length == 1) {
                  if (args[0].equals("-f")) {
                  } else if (args[0].equals("-r")) {
                      try {
                          new DummyRecovery().waitForRecovery();
                      } catch (RuntimeException e) {


      Thanks for the input,


        1 2 Previous Next