1 2 Previous Next 21 Replies Latest reply on Jan 29, 2014 7:35 AM by sdirbach Go to original post
      • 15. Re: Re: JPA Binding - Transaction per Message
        sdirbach

        Looks like it's still trying to use JTA... did you set transaction-type="RESOURCE_LOCAL" on persistence.xml?

        Nope, forgot that point and tried it now:

         

        What happens now, is that all processing is commited until it fails (even the failing entry; In every case, also IN_OUT)

         

        Furthermore the processing of the following entries is still stopped (just as before).

        • 16. Re: Re: Re: JPA Binding - Transaction per Message
          igarashitm

          I modified your application not to use JTA transaction and it did process multiple record in one poll, and the status could be set to FAILED even if the bean threw a checked Exception. Please see testMultipleEntry() testcase.

          • 17. Re: Re: Re: JPA Binding - Transaction per Message
            sdirbach

            Hi,

             

            thanks for your help. I had to set the SwitchYard Version to 1.0 to get it working for me (JBoss FSW 6 Beta + redhat techpreview & redhat integration maven repositories)

             

            The testMultipleEntry() testcase seems to be initiating a rollback for me:

             

            java.lang.AssertionError: expected:<NEW> but was:<PROCESSED>

                at org.junit.Assert.fail(Assert.java:93)

                at org.junit.Assert.failNotEquals(Assert.java:647)

                at org.junit.Assert.assertEquals(Assert.java:128)

                at org.junit.Assert.assertEquals(Assert.java:147)

                at com.example.switchyard.switchyard_database_binding.SwitchyardContainerTest.testEntry(SwitchyardContainerTest.java:75)

                at com.example.switchyard.switchyard_database_binding.SwitchyardContainerTest.testMultipleEntry(SwitchyardContainerTest.java:52)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:622)

                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

                at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:270)

                at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:622)

                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

                at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

                at org.jboss.arquillian.container.test.impl.execution.ContainerTestExecuter.execute(ContainerTestExecuter.java:38)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:622)

                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

                at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:622)

                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:622)

                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)

                at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:622)

                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

                at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)

                at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:263)

                at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:226)

                at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

                at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

                at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)

                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)

                at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

                at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

                at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)

                at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

                at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

                at org.junit.runner.JUnitCore.run(JUnitCore.java:157)

                at org.junit.runner.JUnitCore.run(JUnitCore.java:136)

                at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)

                at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethodInternal(JMXTestRunner.java:128)

                at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethod(JMXTestRunner.java:107)

                at org.jboss.as.arquillian.service.ArquillianService$ExtendedJMXTestRunner.runTestMethod(ArquillianService.java:214)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:622)

                at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:74)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:622)

                at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:277)

                at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:112)

                at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:46)

                at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:226)

                at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)

                at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:253)

                at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:856)

                at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:805)

                at org.jboss.as.jmx.PluggableMBeanServerImpl$TcclMBeanServer.invoke(PluggableMBeanServerImpl.java:527)

                at org.jboss.as.jmx.PluggableMBeanServerImpl.invoke(PluggableMBeanServerImpl.java:263)

                at org.jboss.remotingjmx.protocol.v2.ServerProxy$InvokeHandler.handle(ServerProxy.java:915)

                at org.jboss.remotingjmx.protocol.v2.ServerCommon$MessageReciever$1.run(ServerCommon.java:152)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

                at java.lang.Thread.run(Thread.java:701)

            • 18. Re: JPA Binding - Transaction per Message
              igarashitm

              Can you attach your whole log here? I'm testing on EAP6.1.1+SwitchYard-2.0.0-SNAPSHOT and it succeeds, but it shouldn't be different on FSW6 beta.

              • 19. Re: Re: JPA Binding - Transaction per Message
                sdirbach

                Hi,

                 

                yes, you can find it here

                 

                Sascha

                • 20. Re: Re: Re: JPA Binding - Transaction per Message
                  igarashitm

                  OK, can you try again with longer Thread.sleep() in the test class?

                  
                  
                  
                  --- src/test/java/com/example/switchyard/switchyard_database_binding/SwitchyardContainerTest.java.orig
                  2014-01-28 22:02:12.070174636 +0900
                  
                  
                  +++ src/test/java/com/example/switchyard/switchyard_database_binding/SwitchyardContainerTest.java
                  2014-01-28 22:00:06.617051946 +0900
                  
                  
                  
                  @@ -62,7 +62,7 @@
                           }
                  
                           try {
                  -            Thread.sleep(15l * 1000l);
                  +            Thread.sleep(20l * 1000l);
                           } catch (InterruptedException e) {
                               e.printStackTrace();
                           }
                  

                   

                  I did see the failure you hit on my environment as well, and I understood what's happening there. Once camel JPA consumer detects an Exception, it stops processing and wait next poll, which means the 3rd entry "test2" in the testMultipleEntry is not processed in 1st poll. So if Thread.sleep() returns before the 2nd poll, the entry "test2" is still "NEW" status.

                   

                  BTW, it doesn't matter if you throw checked Exception or RuntimeException to trigger this behavior. Camel JPA handles both of those as failure, just stops current poll and waits for next one.

                  • 21. Re: JPA Binding - Transaction per Message
                    sdirbach

                    Hi,

                     

                    well this may work, but imagine a situation with 1000 entries and a failure rate of 50%. It would take 500 polls to process all entries.

                     

                    Anyway I switched the implementation now to a different architecture.

                     

                    A SwitchYard service with a Quartz binding triggers a CamelRoute, that fetches the entity list through an @Named EJB (via bean-component) then it splits the list and gives it to the processors. The processors are @Named EJBs too.

                     

                    This way I can rollback entries one by one with the normal behaviour (Difference between checked and runtime exceptions, etc)

                     

                    Kind regards,

                     

                    Sascha

                    1 2 Previous Next