5 Replies Latest reply on May 27, 2010 10:45 AM by mferguson

    Synchronous request/reply to an ESB service.

    mferguson

      org.jboss.soa.esb.listeners.message.IncompatibleTransactionScopeException

      Hi I'm still wrestling with how JBoss ESB fits into my application and I have run across a problem that I need some help with.

      I need to send a message to an ESB service from a Seam component in a web application and receive a reply that contains a list that is displayed on a page in the web app. I have implemented the call using ServiceInvoker.deliverSync. When the ServiceInvoker call is made I get an exception:

      16:48:14,970 ERROR [ServiceInvoker] Unexpected throwable during attempted message delivery using Courier for EPR [JMSEpr [
      PortReference < <wsa:Address jms:localhost:1099#queue/registry_service_esb/>,
      <wsa:ReferenceProperties jbossesb:java.naming.factory.initial : org.jnp.interfaces.NamingContextFactory/>,
      <wsa:ReferenceProperties jbossesb:java.naming.provider.url : localhost:1099/>,
      <wsa:ReferenceProperties jbossesb:java.naming.factory.url.pkgs : org.jnp.interfaces/>,
      <wsa:ReferenceProperties jbossesb:destination-type : queue/>, <wsa:ReferenceProperties jbossesb:destination-name :
      queue/registry_service_esb/>, <wsa:ReferenceProperties jbossesb:specification-version : 1.1/>, <wsa:ReferenceProperties
      jbossesb:connection-factory : ConnectionFactory/>, <wsa:ReferenceProperties jbossesb:persistent : true/>,
      <wsa:ReferenceProperties jbossesb:acknowledge-mode : AUTO_ACKNOWLEDGE/>, <wsa:ReferenceProperties jbossesb:transacted : false/>,
      <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/jms/> > ]] for Service [OC_ESB_Internal:RegistryService] and
      Message [header: [ To: JMSEpr [ PortReference < <wsa:Address jms:localhost:1099#queue/registry_service_esb/>,
      <wsa:ReferenceProperties jbossesb:java.naming.factory.initial : org.jnp.interfaces.NamingContextFactory/>,
       <wsa:ReferenceProperties jbossesb:java.naming.provider.url : localhost:1099/>, <wsa:ReferenceProperties
       jbossesb:java.naming.factory.url.pkgs : org.jnp.interfaces/>, <wsa:ReferenceProperties jbossesb:destination-type : queue/>,
       <wsa:ReferenceProperties jbossesb:destination-name : queue/registry_service_esb/>, <wsa:ReferenceProperties
       jbossesb:specification-version : 1.1/>, <wsa:ReferenceProperties jbossesb:connection-factory : ConnectionFactory/>,
       <wsa:ReferenceProperties jbossesb:persistent : true/>, <wsa:ReferenceProperties jbossesb:acknowledge-mode : AUTO_ACKNOWLEDGE/>,
       <wsa:ReferenceProperties jbossesb:transacted : false/>, <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/jms/> > ] ]].
      org.jboss.soa.esb.listeners.message.IncompatibleTransactionScopeException: Request-response attempt within running transaction
      controlling request delivery! Using epr [JMSEpr [ PortReference < <wsa:Address jms:localhost:1099#queue/registry_service_esb/>,
      <wsa:ReferenceProperties jbossesb:java.naming.factory.initial : org.jnp.interfaces.NamingContextFactory/>, <wsa:ReferenceProperties
      jbossesb:java.naming.provider.url : localhost:1099/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.url.pkgs :
      org.jnp.interfaces/>, <wsa:ReferenceProperties jbossesb:destination-type : queue/>, <wsa:ReferenceProperties
      jbossesb:destination-name : queue/registry_service_esb/>, <wsa:ReferenceProperties jbossesb:specification-version : 1.1/>,
      <wsa:ReferenceProperties jbossesb:connection-factory : ConnectionFactory/>, <wsa:ReferenceProperties jbossesb:persistent : true/>,
      <wsa:ReferenceProperties jbossesb:acknowledge-mode : AUTO_ACKNOWLEDGE/>, <wsa:ReferenceProperties jbossesb:transacted : false/>,
      <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/jms/> > ]] for Service [OC_ESB_Internal:RegistryService] and
      Message [header: [ To: JMSEpr [ PortReference < <wsa:Address jms:localhost:1099#queue/registry_service_esb/>,
      <wsa:ReferenceProperties jbossesb:java.naming.factory.initial : org.jnp.interfaces.NamingContextFactory/>,
      <wsa:ReferenceProperties jbossesb:java.naming.provider.url : localhost:1099/>, <wsa:ReferenceProperties
      jbossesb:java.naming.factory.url.pkgs : org.jnp.interfaces/>, <wsa:ReferenceProperties jbossesb:destination-type : queue/>,
      <wsa:ReferenceProperties jbossesb:destination-name : queue/registry_service_esb/>,
      <wsa:ReferenceProperties jbossesb:specification-version : 1.1/>, <wsa:ReferenceProperties jbossesb:connection-factory :
      ConnectionFactory/>, <wsa:ReferenceProperties jbossesb:persistent : true/>, <wsa:ReferenceProperties jbossesb:acknowledge-mode :
      AUTO_ACKNOWLEDGE/>, <wsa:ReferenceProperties jbossesb:transacted : false/>, <wsa:ReferenceProperties jbossesb:type :
      urn:jboss/esb/epr/type/jms/> > ] ]]
       at org.jboss.soa.esb.client.ServiceInvoker$EPRInvoker.attemptDelivery(ServiceInvoker.java:619)
       at org.jboss.soa.esb.client.ServiceInvoker$EPRInvoker.access$200(ServiceInvoker.java:535)
       at org.jboss.soa.esb.client.ServiceInvoker.post(ServiceInvoker.java:355)
       at org.jboss.soa.esb.client.ServiceInvoker.deliverSync(ServiceInvoker.java:215)
       at com.extend.opencase.esb.services.client.AbstractServiceProxy.invokeService(AbstractServiceProxy.java:48)
       at com.extend.opencase.esb.services.client.AbstractServiceProxy.invokeService(AbstractServiceProxy.java:62)
       at com.extend.opencase.esb.services.registry.client.RegistryServiceProxy.getAllServiceNames(RegistryServiceProxy.java:142)
       at com.extend.opencase.cp.controllers.BaseProcessorController.<init>(BaseProcessorController.java:58)
       at com.extend.opencase.cp.controllers.BaseProcessorController_$$_javassist_seam_11.<init>(BaseProcessorController_$$_javassist_seam_11.java)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
       at java.lang.reflect.Constructor.newInstance(Unknown Source)
       at java.lang.Class.newInstance0(Unknown Source)
       at java.lang.Class.newInstance(Unknown Source)
       at org.jboss.seam.Component.wrap(Component.java:1504)
       at org.jboss.seam.Component.instantiateJavaBean(Component.java:1442)
       at org.jboss.seam.Component.instantiate(Component.java:1359)
       at org.jboss.seam.Component.newInstance(Component.java:2122)
       at org.jboss.seam.Component.getInstance(Component.java:2021)
       at org.jboss.seam.Component.getInstance(Component.java:1983)
       at org.jboss.seam.Component.getInstance(Component.java:1977)
       at org.jboss.seam.Component.getInstanceFromFactory(Component.java:2073)
       at org.jboss.seam.Component.getInstance(Component.java:2011)
       at org.jboss.seam.Component.getInstance(Component.java:1983)
       at org.jboss.seam.Component.getInstance(Component.java:1977)
       at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
       at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
       at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:148)
       at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
       at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
       at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
       at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
       at org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
       at org.jboss.el.parser.AstGreaterThan.getValue(AstGreaterThan.java:21)
       at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
       at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
       at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:390)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:924)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
       at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
       at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Unknown Source)
      




      Looking into this I read this in the Programmer's Guide:

      Some Couriers support transactional delivery semantics, e.g., InVM and JMS. The current delivery semantics for such Couriers is based on JMS transacted sessions, i.e., the message is placed on a queue within the scope of a transaction but not actually delivered until the enclosing transaction has committed; it is then pulled by the receiver in the scope of a separate transaction. Unfortunately for synchronous request/response interactions this can result in a timeout waiting for the response since the sender blocks waiting for the response before it can terminate the delivery transaction.
      
      From JBossESB 4.5 onwards we attempt to detect these blocking situations and throw the IncompatibleTransactionScopeException. The application should catch this and act accordingly.
      


      Has anyone else encountered this type of situation, and if so how did you resolve it? Would it make more sense to write a jaxws wrapper for the service and expose it using SOAPProducer? I'm just trying to figure out the proper pattern for this type of interaction, because I am stringing together several JEE application and this is going to come up repeatedly.


        • 1. Re: Synchronous request/reply to an ESB service.
          tfennelly

          Hi there.

          You may be able to suspend the active transaction, otherwise you could do something similar to what you outline.

          • 2. Re: Synchronous request/reply to an ESB service.
            mferguson

            Thanks for your response, Tom.

            It would be nice to have a repository of patterns and examples of real world application situations, because surely making a synchronous RequestResponse call from an ESB-aware client with a running transaction (EJB,l Seam component, etc.) is not an unusual situation. As comprehensive as the quickstart examples are, when you move them to the context of an application that goes beyond the SendJMSMessage/SendESBMessage scenario it's very hard to determine how to proceed.

            I recognize that the purpose of the ESB is to provide flexible options for integration, but there are probably a few scenarios (call from an EJB application, call from a web app) that would cover a lot of users.

            I went back and looked at the Trailblazer application after seeing it mentioned in the docs and it was very helpful. Is there anything roadmapped for a new sample app, or a document describing common patterns?

            • 3. Re: Synchronous request/reply to an ESB service.
              bradsdavis

              Mac, do you mind sharing your final resolution on this issue?

               

              Thanks!

              • 4. Re: Synchronous request/reply to an ESB service.
                bradsdavis
                <action name="call web service">
                  <property name="service-category" value="example-category"/>
                  <property name="service-name" value="ExampleServiceName"/>
                  <property name="suspendTransaction" value="true"/>
                </action>
                

                 

                To do this, add the property suspendTransaction and set it to true.

                • 5. Re: Synchronous request/reply to an ESB service.
                  mferguson

                  I ended up wrapping my calls to ServiceInvoker in a SLSB and  marking the methods with a

                   

                  @TransactionAttribute

                  (TransactionAttributeType.NOT_SUPPORTED)

                   

                  annotation, which seems to work pretty well.