8 Replies Latest reply on Jan 3, 2017 9:01 AM by maheshnaidu

    How to execute Service Task One by One

    jay4smile

      I have created one Sample bpmn FIle..

       

      in which

      1)Start Event

      2) validation Service Process (created by me)

      3) if its successful then  Call webservice Service Task (also created by me)

      4) if its unsuccessful then END

       

       

                            Start

      |

      |

      validation event

      |

      Gateway(Diverge)

      /\

            /   \

      true     false------> END

      |

      |

      Service Task

      (execute web Service)

             |

             |

          END

       

      Now My Question is How to call service Task One by One depending the the Result of another Process?

       

      Please help me!

        • 1. Re: How to execute Service Task One by One
          eaa

          I'm not sure in what you mean by "One by One", but if your question is how you get some result from the first task so you can make a decision in your gateway the answer is to have a process variable (you already have 'loginStatus' variable) and then assign the output of the first task into the process variable. Then, in the flows coming out of your gateway you can write something like: "return loginStatus == true;".

          Hope it helps.

           

          Best Regards,

          • 2. Re: How to execute Service Task One by One
            jay4smile

            One by One means.

             

            on Basis of loginStatus I want to execute another Service Task.

             

            as per bpmn File. I have created Service Task for web Service.

             

            on LoginStatus==true; I want to execute that.

             

            to execute it I have written..

             

                      ksession.getWorkItemManager().registerWorkItemHandler("validation", new SimpleWorkhandler());

              //KnowledgeRuntimeLogger logger = KnowledgeBuilderFactory.newFileLogger("test");

                                Map<String,Object> params = new HashMap<String,Object>();

                                params.put("userName", "jay4smile@yahoo.com");

                                params.put("password", "jay123");

                                ksession.startProcess("com.sample.bpmn",params);

             

                                ksession.getWorkItemManager().registerWorkItemHandler("WebServicesCall", new SearchBookHandler());

                                ksession.startProcess("com.sample.bpmn");

             

            First Process executed Normally.

            but for second process "webServicesCall"

            I am getting Error Like "

            bpm.workflow.instance.WorkflowRuntimeException: [com.sample.bpmn:1 - Web Service:2] -- Could not find work item handler for WebServicesCall

            "

             

            and I already Created the SearchBookHandler Class for WebServicesCall Service Task

             

            I hope u understood!!

             

            My Question is "How Can I execute Another Process or Processes??"

             

            How to configure it??

            • 3. Re: How to execute Service Task One by One
              eaa

              Are you sure you are getting that error when you try to start the second process instance and not in the first try?

              A common practice is to configure all the hanlders before starting any process instance since you may not know which path of the process is going to be executed.

              • 4. Re: How to execute Service Task One by One
                jay4smile

                Ya I am Sure,

                As in Validation Service Task I am calling Web Service for Login.

                 

                and I am Getting the perfact Output.

                 

                and then getting the above Error..

                 

                But I found something interesting..

                 

                Some times the execution flow is perfact means it executed first Process ... getting the output for First Process and then getting error

                and sometimes ... executed First Process then Getting the above Error and then Getting Output of the First Process...

                Why so?

                ----

                Ok..

                Can you tell me how to configure all the Service Task before starting the Processes???

                Do you have any example of that!!

                 

                Thanks and Regards,

                Jay Patel

                • 5. Re: How to execute Service Task One by One
                  eaa

                  Just move up this line:

                    ksession.getWorkItemManager().registerWorkItemHandler("WebServicesCall", new SearchBookHandler());

                   

                  Something like this:

                   

                  //Register Work Item Handlers:

                  ksession.getWorkItemManager().registerWorkItemHandler("validation", new SimpleWorkhandler());

                  ksession.getWorkItemManager().registerWorkItemHandler("WebServicesCall", new SearchBookHandler());

                   

                  //Start first instance

                  Map<String,Object> params = new HashMap<String,Object>();

                  params.put("userName", "jay4smile@yahoo.com");

                  params.put("password", "jay123");

                  ksession.startProcess("com.sample.bpmn",params);

                   

                  //start second instance

                  ksession.startProcess("com.sample.bpmn");

                   

                   

                  Best Regards,

                  • 6. Re: How to execute Service Task One by One
                    jay4smile

                    Thanks a lot,

                     

                    The issue is solved now!,

                     

                    According to above Answer ,

                    Suppose I have 10 Service Task in my bpmn file..

                    I have to register all of them before start the Process right??

                     

                    Thanks and Regards,

                    Jay Patel

                    • 7. Re: How to execute Service Task One by One
                      eaa

                      That's right. Otherwise, before starting a process you must know its execution path to see if you have all the handlers in place. Registering 'unnecessary' handlers is harmless, so don't worry if in one of your executions you are not using it.

                       

                      Best Regards,

                      • 8. Re: How to execute Service Task One by One
                        maheshnaidu

                        Can you please tell how you have used the output given from validation event to form a condition in gateway.

                         

                        Thanks,

                        Vijay