5 Replies Latest reply on May 26, 2016 8:45 AM by Tomohisa igarashi

    Where to set ROLLBACK_ON_FAULT ("org.switchyard.rollbackOnFault")?

    Jochen Riedlinger Newbie

      Hi,

       

      we have two scenarios in which we have trouble that messages get lost if using JMS/JCA(A-MQ) endpoints.

       

      1.) A JMS Service Binding uses a Java Operation Selector (org.switchyard.selector.OperationSelector<T>). If an Exception aoccurs in this implementation the message is lost, because despite the error no rollback occurs.

      I know that I have to put org.switchyard.Exchange.ROLLBACK_ON_FAULT/"org.switchyard.rollbackOnFault" on the Switchyard Context. Unfortunately I cannot access org.switchyard.Context within my implementation of OperationSelector.

       

      Where can I set "org.switchyard.rollbackOnFault" so that an Exception in an OperationSelector or a ContextMapper triggers a rollback so that the message stays in the queue, instead of getting lost?

       

      I tried to put it as Domain Property, but that doesn't work either. But I think that would be the best solution if I just want this behaviour for the whole Switchyard application.

       

      2.) Almost the same for JMS reference Bindings. If we have two <to...> references in a Camel component, both should be rolled back if one has an error (e.g. in a MessageComposer for the resonse). But here it's possible to have a workaround using the Camel configuration.

       

      Best regards,

      Jochen

        • 1. Re: Where to set ROLLBACK_ON_FAULT ("org.switchyard.rollbackOnFault")?
          Tomohisa igarashi Master

          That's weird. for JCA/JMS service binding if OperationSelector throws Exception then transaction should be rolled back here

          switchyard/EndpointProxy.java at master · jboss-switchyard/switchyard · GitHub

          switchyard/EndpointProxy.java at master · jboss-switchyard/switchyard · GitHub

           

          Can you attach a minimal reproducer project here?

          • 2. Re: Where to set ROLLBACK_ON_FAULT ("org.switchyard.rollbackOnFault")?
            Jochen Riedlinger Newbie

            Thanks for the link to the relevant lines of code.

            I haven't created a small reprocuder yet, but I started debugging with my real project.

            Unfortunately line 320 is never reached, because in line 319 the variable "commit" is true, although I have created a NullPOinterExcpetion in my custom Operation Selector....

             

            This is the Stacktrace:

            RK3983nodeESB1 | 2016-05-23 11:37:13.126 | ERROR | org.apache.activemq.ActiveMQSession | default-threads - 13 | error dispatching message: : java.lang.reflect.UndeclaredThrowableException

                at com.sun.proxy.$Proxy120.onMessage(Unknown Source)

                at org.apache.activemq.ra.MessageEndpointProxy$MessageEndpointAlive.onMessage(MessageEndpointProxy.java:123)

                at org.apache.activemq.ra.MessageEndpointProxy.onMessage(MessageEndpointProxy.java:64)

                at org.apache.activemq.ActiveMQSession.run(ActiveMQSession.java:1038)

                at org.apache.activemq.ra.ServerSessionImpl.run(ServerSessionImpl.java:169)

                at org.jboss.jca.core.workmanager.WorkWrapper.run(WorkWrapper.java:215)

                at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33)

                at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:808)

                at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45)

                at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:828)

                at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_71]

                at org.jboss.threads.JBossThread.run(JBossThread.java:122)

            Caused by: java.lang.reflect.InvocationTargetException

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_71]

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_71]

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_71]

                at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_71]

                at org.switchyard.component.jca.EndpointProxy.delivery(EndpointProxy.java:194) [switchyard-component-jca-2.0.1.redhat-621107.jar:2.0.1.redhat-621107]

                at org.switchyard.component.jca.EndpointProxy.invoke(EndpointProxy.java:159) [switchyard-component-jca-2.0.1.redhat-621107.jar:2.0.1.redhat-621107]

                ... 12 more

            Caused by: org.switchyard.SwitchYardException: java.lang.NullPointerException

                at org.switchyard.component.jca.endpoint.JMSEndpoint.onMessage(JMSEndpoint.java:211) [switchyard-component-jca-2.0.1.redhat-621107.jar:2.0.1.redhat-621107]

                ... 18 more

            Caused by: java.lang.NullPointerException

                at org.switchyard.component.jca.endpoint.JMSEndpoint.onMessage(JMSEndpoint.java:172) [switchyard-component-jca-2.0.1.redhat-621107.jar:2.0.1.redhat-621107]

                ... 18 more

            | org.apache.activemq.ActiveMQSession.run(ActiveMQSession.java:1041)

             

             

            org.switchyard.component.jca.endpoint.JMSEndpoint

            throws a SwitchyardExpeption, that wraps the NullPOinterExcpetion from line 172

                 final String operation = _selector != null ? _selector.selectOperation(bindingData).getLocalPart() : null;

            where .getLocalPart() cuases the NullPointer.

             

            But why is a UndeclaredThrowableException in the stacktrace?

            We have our switchyard application deploeyed within an EAR, but "jboss-deployment-structure.xml" contains <module name="org.switchyard.api" export="true" />

             

             

            I'll try to post a reproducer later today

            • 3. Re: Where to set ROLLBACK_ON_FAULT ("org.switchyard.rollbackOnFault")?
              Jochen Riedlinger Newbie

              Hi,

               

              here's my reproducer.

              I just took the "jca-inflow-activemq" quickstart and replaced the XPath operation selector with a Java operation selector that returns null (which happend in our real code because logic didn't find a result).

               

              Do you think this is a bug?

              I think I'll open a support case....

              • 4. Re: Where to set ROLLBACK_ON_FAULT ("org.switchyard.rollbackOnFault")?
                Jochen Riedlinger Newbie

                I just recognized that the reproducer can even be simpler.

                the original "jca-inflow-activemq" quickstart shows the same behaviour if you use an XPATH expression that has no match....

                 

                RK3983nodeESB1 | 2016-05-24 08:57:04.160 | ERROR | org.apache.activemq.ActiveMQSession | default-threads - 7 | error dispatching message: : java.lang.reflect.UndeclaredThrowableException

                    at com.sun.proxy.$Proxy57.onMessage(Unknown Source)

                    at org.apache.activemq.ra.MessageEndpointProxy$MessageEndpointAlive.onMessage(MessageEndpointProxy.java:123) [activemq-ra-5.11.0.redhat-621107.jar:5.11.0.redhat-621107]

                    at org.apache.activemq.ra.MessageEndpointProxy.onMessage(MessageEndpointProxy.java:64) [activemq-ra-5.11.0.redhat-621107.jar:5.11.0.redhat-621107]

                    at org.apache.activemq.ActiveMQSession.run(ActiveMQSession.java:1038) [activemq-client-5.11.0.redhat-621107.jar:5.11.0.redhat-621107]

                    at org.apache.activemq.ra.ServerSessionImpl.run(ServerSessionImpl.java:169) [activemq-ra-5.11.0.redhat-621107.jar:5.11.0.redhat-621107]

                    at org.jboss.jca.core.workmanager.WorkWrapper.run(WorkWrapper.java:215) [ironjacamar-core-impl-1.0.36.Final-redhat-1.jar:1.0.36.Final-redhat-1]

                    at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33)

                    at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:808)

                    at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45)

                    at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:828)

                    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_71]

                    at org.jboss.threads.JBossThread.run(JBossThread.java:122)

                Caused by: java.lang.reflect.InvocationTargetException

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_71]

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_71]

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_71]

                    at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_71]

                    at org.switchyard.component.jca.EndpointProxy.delivery(EndpointProxy.java:194) [switchyard-component-jca-2.0.1.redhat-621107.jar:2.0.1.redhat-621107]

                    at org.switchyard.component.jca.EndpointProxy.invoke(EndpointProxy.java:159) [switchyard-component-jca-2.0.1.redhat-621107.jar:2.0.1.redhat-621107]

                    ... 12 more

                Caused by: org.switchyard.SwitchYardException: java.lang.Exception: SWITCHYARD034503: No node has been matched with the XPath expression '//*[local-name()='personXXX' and namespace-uri()='urn:switchyard-quickstart:jca-inflow-activemq:0.1.0']/language' in the payload. It couldn't determine the operation.

                    at org.switchyard.component.jca.endpoint.JMSEndpoint.onMessage(JMSEndpoint.java:211) [switchyard-component-jca-2.0.1.redhat-621107.jar:2.0.1.redhat-621107]

                    ... 18 more

                Caused by: java.lang.Exception: SWITCHYARD034503: No node has been matched with the XPath expression '//*[local-name()='personXXX' and namespace-uri()='urn:switchyard-quickstart:jca-inflow-activemq:0.1.0']/language' in the payload. It couldn't determine the operation.

                    at org.switchyard.component.common.selector.BaseOperationSelector.xpathMatch(BaseOperationSelector.java:121) [switchyard-component-common-2.0.1.redhat-621107.jar:2.0.1.redhat-621107]

                    at org.switchyard.component.common.selector.BaseOperationSelector.selectOperation(BaseOperationSelector.java:66) [switchyard-component-common-2.0.1.redhat-621107.jar:2.0.1.redhat-621107]

                    at org.switchyard.component.jca.endpoint.JMSEndpoint.onMessage(JMSEndpoint.java:172) [switchyard-component-jca-2.0.1.redhat-621107.jar:2.0.1.redhat-621107]

                    ... 18 more