8 Replies Latest reply on Aug 11, 2008 5:21 AM by Kevin Conner

    NewProcessInstanceFacade &  reply-to-originator &   null 'va

    Jarkko Lietolahti Novice

      Is this piece of code from NewProcessInstanceFacade correct?

       if (_replyToOriginator) {
       final Call call = message.getHeader().getCall() ;
       body.add(Constants.REPLY_TO, getEPR(call.getReplyTo())) ;
       body.add(Constants.FAULT_TO, getEPR(call.getFaultTo())) ;
       }
      


      Because it seems to cause
      java.lang.IllegalArgumentException: null 'value' arg in method call.
       at org.jboss.internal.soa.esb.assertion.AssertArgument.isNotNull(AssertArgument.java:43)
       at org.jboss.internal.soa.esb.message.format.xml.BodyImpl.add(BodyImpl.java:81)
       at org.jboss.soa.esb.services.jbpm.cmd.NewProcessInstanceFacade.setJBPMContextParameters(NewProcessInstanceFacade.java:97)
       at org.jboss.soa.esb.services.jbpm.actions.BpmProcessor.process(BpmProcessor.java:73)
      


      I've
       <property name="reply-to-originator" value="true"/>
      

      in jboss-esb.xml.

      I even tried
       <property name="fault-to-originator" value="true"/>
      

      but it didn't seem to work ;)

      I'm using ServiceInvoker.deliverSync.


        • 1. Re: NewProcessInstanceFacade &  reply-to-originator &   null
          Jarkko Lietolahti Novice

          What I'm trying to archive is a setup like this:

          1. Client call WebService
          2. WebService calls ESB using ServiceInvoker
          3. ServiceInvoker calls ESB Service
          4. ESB Service starts JBPM process
          6. JBPM process does all the orchestration and calls several ESB services on they way. ESB services fill the message with relevant data. After the process is completed/ended call should return to webservice which should be waiting in deliverSync.
          7. Webservice has a replyMessage from serviceInvoker.deliverSync with the data in it
          8. WebService gets the data from replyMessage and returns it to the Client.
          9. Client is happy with the data

          The problem is there that I don't know how to configure (or can't get it to work) the ESB service to "hang" until the process has completed and return the data to the caller. What happens is that the JBPM process starts and starts it's own life and the esb service continues its action pipeline until the call is returned to the Webservice.

          I think this could be done with ServiceInvoker and confguring the JBPM startup with property reply-to-originator=true.

          I'll keep digging around.




          • 2. Re: NewProcessInstanceFacade &  reply-to-originator &   null
            Kevin Conner Master

            This was previously possible by manually storing the EPRs as part of the process instance creation and then creating an action which would use this to deliver a message to that EPR.

            The 4.4 GA release now includes explicit support for this within the jBPM integration. Take a look at the comments in https://jira.jboss.org/jira/browse/JBESB-1457.

            • 3. Re: NewProcessInstanceFacade &  reply-to-originator &   null
              Kevin Conner Master

              Actually, I see from your first comment that you are already using this.

              Let me look into it.

              • 4. Re: NewProcessInstanceFacade &  reply-to-originator &   null
                Kevin Conner Master

                Sorry, this is my fault. I'll get this fixed asap.

                • 6. Re: NewProcessInstanceFacade &  reply-to-originator &   null
                  Kevin Conner Master

                  BTW The workaround is to set the fault to EPR to the same EPR as the reply to.

                  • 7. Re: NewProcessInstanceFacade &  reply-to-originator &   null
                    Jarkko Lietolahti Novice

                    Thanks for the fix in SVN.
                    I got my example working, but I'm still little suspicious.
                    The only way to get a response back from the JBPM was to set mep="OneWay".
                    If mep="RequestResponse" the actionpipeline would return before the JBPM process
                    got it's job done, thus returning a message without the datta to the client.

                    Is this working as intended?

                    Client code:

                    RequestMessage requestMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
                    // fill requestMessage with data
                    Message reply = invoker.deliverSync(requestMessage, 70000000);
                    


                    Service definition from jboss-esb.xml
                     <service category="testing"
                     description="A service to test JBPM process returning data" name="jbpm">
                     <listeners>
                     <jms-listener
                     busidref="gateway" is-gateway="true"
                     maxThreads="1" name="JMS-Gateway" />
                     <jms-listener
                     busidref="esb" maxThreads="1"
                     name="esb" />
                     </listeners>
                    
                     <actions mep="OneWay">
                     <action class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor" name="create_new_process_instance">
                     <property name="command" value="StartProcessInstanceCommand"/>
                     <property name="process-definition-name" value="testProcess"/>
                     <property name="reply-to-originator" value="true"/>
                     <property name="esbToBpmVars">
                     <mapping bpm="theBody" default="" esb="BODY_CONTENT"/>
                     <mapping bpm="requestParam1" esb="requestParam1"/>
                     <mapping bpm="requestParam2" esb="requestParam2"/>
                     </property>
                     </action>
                     </action>
                    



                    The process calls ESB services which populate the message with data and then in end state sends it back to the ESB;
                     <end-state name="end1">
                     <event type="node-enter">
                     <action name="notify" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbNotifier">
                     <bpmToEsbVars>
                     <mapping bpm="theBody" esb="BODY_CONTENT" />
                     <mapping bpm="products" esb="products"></mapping>
                    
                     </bpmToEsbVars>
                     <replyToOriginator>reply</replyToOriginator>
                     </action>
                     </event>
                     </end-state>
                    


                    This is the replyMessage when mep="OneWay"
                     [java] message: [ JBOSS_XML ]
                     [java] header: [ To: JMSEpr [ PortReference < <wsa:Address jms://localhost/queue/esb_reply/>, <wsa:ReferenceProperties
                     jbossesb:java.naming.provider.url : jnp://127.0.0.1:1099/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.initial :
                     org.jnp.interfaces.NamingContextFactory/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.url.pkgs : org.jboss.naming:org.jnp.interfaces/>,
                     <wsa:ReferenceProperties jbossesb:destination-type : queue/>, <wsa:ReferenceProperties jbossesb:specification-version : 1.1/>,
                     <wsa:ReferenceProperties jbossesb:connection-factory : ConnectionFactory/>, <wsa:ReferenceProperties jbossesb:message-selector :
                     jbossESBresponseUUID='23873dfd-2960-45b8-8624-0e4bfd962872'/>, <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/> > ]
                    MessageID: 634330b5-8d8e-4e3c-bcef-6c980bb43986 RelatesTo: jms:correlationID#634330b5-8d8e-4e3c-bcef-6c980bb43986 ]
                     [java] context: [ ]
                     [java] body: [ objects: {org.jboss.soa.esb.message.defaultEntry=Deferred serialized value: 823d278, org.jboss.soa.esb.message.defaultEntry-set-stack=Deferred serialized value: 67cec874, products=Deferred serialized value: 38ca6cea} ]
                     [java] fault: [ ]
                     [java] attachments: [ Named:{}, Unnamed:[] ]
                     [java] properties: [ {jbossESBresponseUUID=23873dfd-2960-45b8-8624-0e4bfd962872, org.jboss.soa.esb.message.byte.size=9039, org.jboss.soa.esb.message.time.dob=Deferred serialized value: 71b493c6, org.jboss.soa.esb.message.source=Deferred serialized value: 651e67c, org.jboss.soa.esb.message.transport.type=Deferred serialized value: 6af2da21, JMSXDeliveryCount=1, javax.jms.message.redelivered=false} ]
                     [java] Got 5 products back!
                    


                    This is the reply message with mep="RequestResponse"
                     [java] message: [ JBOSS_XML ]
                     [java] header: [ To: JMSEpr [ PortReference < <wsa:Address jms://localhost/queue/esb_reply/>, <wsa:ReferenceProperties
                     jbossesb:java.naming.provider.url : jnp://127.0.0.1:1099/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.initial :
                     org.jnp.interfaces.NamingContextFactory/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.url.pkgs : org.jboss.naming:org.jnp.interfaces/>,
                     <wsa:ReferenceProperties jbossesb:destination-type : queue/>, <wsa:ReferenceProperties jbossesb:specification-version : 1.1/>,
                    <wsa:ReferenceProperties jbossesb:connection-factory : ConnectionFactory/>, <wsa:ReferenceProperties jbossesb:message-selector :
                     jbossESBresponseUUID='5edf5637-4388-49b2-b4b5-6f428336d9c8'/>, <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/> > ] From: JMSEpr [ PortReference < <wsa:Address jms://localhost:1099/queue/esb/>,
                     <wsa:ReferenceProperties jbossesb:java.naming.factory.initial : org.jnp.interfaces.NamingContextFactory/>,
                    <wsa:ReferenceProperties jbossesb:java.naming.provider.url : jnp://127.0.0.1:1099/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.url.pkgs :
                     org.jboss.naming:org.jnp.interfaces/>, <wsa:ReferenceProperties jbossesb:destination-type : queue/>
                     <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/> > ]
                     MessageID: 9c2c959a-77b5-4438-beae-c9d13391ba9e RelatesTo: ea5e119b-8d03-41d3-b113-fb399862236f ]
                     [java] context: [ ]
                     [java] body: [ objects: {requestParam1=Deferred serialized value: 38ca6cea, jbpmVariableMappings=Deferred serialized value: 71b493c6, requestParam2=Deferred serialized value: 651e67c, jbpmCommandCode=Deferred serialized value: 6af2da21, jbpmReplyTo=Deferred serialized value: 6dcee361, jbpmProcessDefName=Deferred serialized value: 29b22d99} ]
                     [java] fault: [ ]
                     [java] attachments: [ Named:{}, Unnamed:[] ]
                     [java] properties: [ {org.jboss.soa.esb.message.time.dod=Deferred serialized value: 70cfad31, jbossESBresponseUUID=5edf5637-4388-49b2-b4b5-6f428336d9c8, org.jboss.soa.esb.message.byte.size=10608, org.jboss.soa.esb.message.time.dob=Deferred serialized value: 5273a5d3, org.jboss.soa.esb.message.source=Deferred serialized value: 268be9ef, org.jboss.soa.esb.message.transport.type=Deferred serialized value: 2bab5dae, javax.jms.message.redelivered=false, JMSXDeliveryCount=1} ]
                     [java] Something went wrong, we got reply, but it didn't contain products!!
                    


                    In here https://jira.jboss.org/jira/browse/JBESB-1436 it says; "By definition a 'OneWay' service will never return a response."

                    Maybe this is working as meant, but some clarification would help understand what's happening and why.
                    So that the attribute "mep" doesn't become like Hib's "inverse" did ;)






                    • 8. Re: NewProcessInstanceFacade &  reply-to-originator &   null
                      Kevin Conner Master

                       

                      "jarkko@jab.fi" wrote:
                      Thanks for the fix in SVN.
                      I got my example working, but I'm still little suspicious.
                      The only way to get a response back from the JBPM was to set mep="OneWay".
                      If mep="RequestResponse" the actionpipeline would return before the JBPM process
                      got it's job done, thus returning a message without the datta to the client.

                      Is this working as intended?

                      It depends on your intention to be honest.

                      If you want a request/reply message exchange, with the reply message coming from the business process instead of the pipeline, then you need to prevent the pipeline from replying by setting the mep to OneWay. So in this case it is correct.

                      A OneWay service does not mean that a client never sees a response, it just means that the response is not generated from the current pipeline. There is nothing preventing a subsequent service/business process from generating the response to the client.

                      You can see an example of this type of asynchronous behaviour on the following wiki page.

                      http://wiki.jboss.org/wiki/AsyncContinuation