6 Replies Latest reply on Mar 20, 2011 9:27 PM by chuaky

    Help with Scenario

    davidmpaz

      Hello, I would like to ask some things, first allow me to explain what I need to achieve.

       

      In our work we want to set up several esb services that will be orchestrated with jboss jbpm, we sucessfully deploy the services and jbpm process so services are invoked well, our misunderstanding start with mesages passed to each service, our current scenario is:

       

      http gateway receive a post from another application -> http_gateway start a process instance with "StartProcessInstanceCommand" -> process invoke "Service1" -> process wait some time -> process invoke "Service2" ...etc in general that is the thing.

       

      Our questions are;

       

      1. Service1 receive a "org.jboss.soa.esb.http.HttpRequest" ? I have try to handle as if it was one (following http://community.jboss.org/wiki/HTTPGateway#Request_Information) but no succes.
      2. If from Service1 we create a new message and return it, Service2 doesn't seem to receive it, instead receive the one received by Service1 too. So, how can we modify the message from one service invocation to another? in a way that changes could be check in other services.

       

      We really want this kind of scenario of having services being orchestated by jbpm. So any help/sugestion or correction in our conceptions will be aprpreciated, if needed I can post our testing config files also the process definition.

        • 1. Re: Help with Scenario
          scottdawson

          David,

            Regarding question 1, the httpgateway quickstart shows a simple example of the use of the HttpRequest object. What problem are you having?

          Regards,

          Scott

          • 2. Re: Help with Scenario
            davidmpaz

            Hi, thanks for the quick reply.

             

            My confusion is that (founded yesterday after writing the post) message arrive as byte[], as explained in docs for http_gateway/payload decoding and I was trying to handle as HttpRequest, I think my problem now is how to extract usefull information from the message coming as byte[] since http_gateway receives a post from a php page using curl.

             

            For make my self more clear, this is my service configfuration for the http_gateway:

             

             

            {code:xml}

            <service category="UclvHTTPStarterService" name="HTTPStarterService"
                        description="Use this service to start a process instance through http"
                        invmScope="GLOBAL">
                        <listeners>
                           
                            <http-gateway name="starter" busidref="secureChanel"
                                urlPattern="starter/*">
                                <asyncResponse statusCode="202" />
                            </http-gateway>
                        </listeners>
                        <actions mep="RequestResponse">
                            <!--<action name="preproces" class="cu.edu.uclv.uchannel.http.HTTPCreateUser"
                                process="process" />
                            --><action name="http_create_new_process_instance"
                               >
                                <property name="command" value="StartProcessInstanceCommand" />
                                <property name="process-definition-name" value="UclvUserCreation" />
                                <property name="esbToBpmVars">
                                    <mapping esb="BODY_CONTENT" bpm="theBody" />
                                </property>
                            </action>               
                        </actions>
            </service>

            {code}

             

            now, when processing the message in the commented action I sucessfully get the HttpRequest like this:

             

            {code}

            HttpRequest requestInfo = HttpRequest.getRequest(message);

            {code}

             

            again, just as explained in docs, but when using the configuration above, to the service invoked by the jbpm process arrive a byte array. I could make a work around and in the gateway make send a jms message with the HttpRequest as body content but that will be another call and more unnessary processing. I have also try as you could imagine to preprocess the message in the action commented and then passing it to the other action but still getting the same message (as byte array) in the services invoked by the process. So I hope I explain my issue well, maybe I should reformulate that question  (the second question remain) .

             

            How can I extract the usefull posted data from the byte array, there is a way that does't involve converting it to string and parsing it?

             

            thanks a lot for listen and help.

             

            Greetings David

            • 3. Help with Scenario SOLVED !!!
              davidmpaz

              Problem solved. Sorry for bothering with such a newbie question, I miss a really important part from the first quickstart about ESB JBPM integration, this line:

              {code:xml}

              <mapping esb="BODY_CONTENT" bpm="theBody" />

              {code}

              maps the message to the variable theBody but as byte[] since it is done as getContent() do

               

              Everything works smoothly after doing required mappings for the vars I needed inside the message to pass from one service to another. the config looks now like this:

               

              {code:xml}

              <service category="UclvHTTPStarterService" name="HTTPStarterService"
                          description="Use this service to start a process instance through http"
                          invmScope="GLOBAL">
                          <listeners>
                             
                              <http-gateway name="starter" busidref="secureChanel"
                                  urlPattern="starter/*">
                                  <asyncResponse statusCode="202" />
                              </http-gateway>
                          </listeners>
                          <actions mep="RequestResponse">
                              <!--extract http request and set up var needed-->
                              <action name="preproces" class="cu.edu.uclv.uchannel.http.HTTPCreateUser"
                                  process="process" />
                              <action name="http_create_new_process_instance">
                                  <property name="command" value="StartProcessInstanceCommand" />
                                  <property name="process-definition-name" value="UclvUserCreation" />
                                  <property name="esbToBpmVars">
                                      <mapping esb="body.user_name" bpm="user_name" />
                                      <mapping esb="body.user_password" bpm="user_password" />
                                      ..........
                                  </property>
                              </action>               
                          </actions>
              </service>

              {code}

               

              And of course the similar things in the process definition.

               

              Thanks a lot for listen and sorry for the time taken.

               

              Greetings David

              • 4. Help with Scenario
                chuaky

                hi David n any1,

                 

                I encountered the same problem while using http gateway to receive a Http Post and then do some business processing using jbpm in esb.  What i don't understand is the byte[] in the message body used by http gateway, in how it causes problem in using "BODY_CONTENT"?

                 

                Hope some1 can help,

                Thanks.

                • 5. Re: Help with Scenario
                  davidmpaz

                  Hi,

                   

                  taking a look to this:

                   

                  {code:xml}<property name="esbToBpmVars"><mapping esb="BODY_CONTENT" bpm="theBody" /></property>{code}

                   

                  if doing it this way then the jbpm will receive data as a byte[] and not as was the spected variables like doing it like this:

                   

                  {code:xml}

                  <property name="esbToBpmVars">

                                          <mapping esb="body.user_name" bpm="user_name" />

                                          <mapping esb="body.user_password" bpm="user_password" />
                                          ..........

                                      </property>

                  {code}

                   

                  this way in jbpm you can refer to it as it is by their names "user_password" and not as an entire byte stream. Of course mappings in jbpm to do the inverse was needed too.

                   

                  I just wanted to have each var separated to work with and not as an string.

                   

                  Hope this help

                  • 6. Help with Scenario
                    chuaky

                    Thanks David for the advice, will try it out.