How to propagate transactions via SCA binding in SwitchYard

Solution Unverified - Updated -

Issue

  • We have two services Hello and World. When Hello uses the UserTransaction and calls World before doing commit, an error occurs.

    @Service(HelloService.class)
    public class HelloServiceBean implements HelloService {
    
        @Reference @Inject
        private WorldService worldService;
        @Inject
        private UserTransaction utx;
    
        @Override
        public void doTest() {
            try {
                utx.begin();
                worldService.doTest();
                utx.commit();
            } catch (Exception e) {
                try {
                    if (utx.getStatus() == Status.STATUS_ACTIVE || utx.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
                        utx.rollback();
                    }
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
    
  • We do not want to suspend the current transaction and we are invoking the service via SCA.

  • How can we propagate the transaction to the invoked service?

Environment

  • Red Hat JBoss Fuse Service Works (FSW)
    • 6.0
  • Red Hat JBoss Fuse
    • 6.2

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.