10 Replies Latest reply on Oct 19, 2009 8:07 PM by Ronald van Kuijk

    [jBPM4] Synchronous process execution

    Cavaco Silva Newbie

      Hi all,

      I'm starting a process with executionService.startProcessInstanceByKey(...) and I want to wait for its end (without polling isEnded()), how can I do this? I've inspected the ProcessInstance, Execution API's and cannot find anything related to this. I just want to run a process Synchronously.

      Thanks,
      Sergio

        • 1. Re: [jBPM4] Synchronous process execution
          Ronald van Kuijk Master

          then make sure you have no tasks, waitstates etc... it will run synchronously then.

          • 2. Re: [jBPM4] Synchronous process execution
            Cavaco Silva Newbie

            Hi Ronald,

            Maybe I did not explain my self correctly, sorry. I don't understand very well what you say, but now I'm invoking the startProcess and it returns immediately and my process stays on a waiting state. What I need is to call the executionService.startProcessInstanceByKey(...) and wait for the process end, without active waiting. I mean, the caller calls the startProcess* and waits for its end. The process is complex and has multiple human tasks.
            In addition, is there any callback that can be used to communicate the process end to the caller?

            Thanks,
            Sergio

            • 3. Re: [jBPM4] Synchronous process execution
              Ronald van Kuijk Master

              You explained very well, and I fully understood.

              That cannot be done blocking... for the very simple reason that you'd need way to many (java) threads etc. Callback can be done very easily by eventhandlers on the end node and notify the 'caller'.

              • 4. Re: [jBPM4] Synchronous process execution
                Ronald van Kuijk Master

                Oh.. and the only way to achieve real waiting is what I described in my previous post (STP)

                • 5. Re: [jBPM4] Synchronous process execution
                  Cavaco Silva Newbie

                  Thanks for your response Ronald.
                  I understand what you are saying, but in my opinion the "to many (java) threads" should be at the user consideration, if I want to use them, the jBPM should give that option. There are some actions that must be sequenced by nature, just think in on the JBoss ESB action pipeline that I'm using. By nature the action pipeline is synchronous, but if I invoke a jBPM process I will lose that synchronism or else I have to implement some blocking mechanism my self, which is uglier than the jBPM supporting it intrinsically.
                  I searched for the keyword STP in the jBPM users forum but did not find any thing useful, which previous post are you referring to?

                  Thanks,
                  Sergio

                  • 6. Re: [jBPM4] Synchronous process execution
                    Ronald van Kuijk Master

                     

                    I understand what you are saying, but in my opinion the "to many (java) threads" should be at the user consideration, if I want to use them, the jBPM should give that option.

                    It's not something that could/should not be in jBPM, it's just that the combination of having a blocking process with waitstates is not something that has been requested a lot before (at all afaik) so there simple was not any time spent in realizing this.

                    With my 'previous post' I refered to the post in this topic, sorry for the confusion. Like I said, jBPM supports executing synchronous services and is blocking IF the services you call are all synchrounous. Since you do not seem to have a problem with blocking threads, you can create blocking services. That is even cleaner than jBPM providing it 'intrisically' ;-).

                    So this way you do not lose the 'synchronism' and I still think a thread blocking for possible long period (since you have human task) is a wrong design of a system with many downsides and possible problems like transactiontimeouts, etc.Maybe it is time to rethink some of your architecture.

                    • 7. Re: [jBPM4] Synchronous process execution
                      Cavaco Silva Newbie

                      Ok Ronald, thanks for your clarification. Just by curiosity, my architecture is simple, what I want is a simple JBoss ESB service where there are two actions, the first action calls a JBPM process and the second action should not start before the first action fully ends (Process ends) because it depends from it and because of that is next in the pipeline and I don't want it to be executed in parallel with the first action. Do you see a way to do this?

                      Many Thanks,
                      Sergio

                      • 8. Re: [jBPM4] Synchronous process execution
                        Ronald van Kuijk Master

                        create a new 'main'jbpm process which calls a subprocess (the process you have now) and after that call an esb service. plain and simple.....

                        • 9. Re: [jBPM4] Synchronous process execution
                          Cavaco Silva Newbie

                          Well, you are just saying, don't use the ESB action pipeline but do it in a process, this is arguable, but I understand your message. Thank you for your response.

                          Regards,
                          Sergio

                          • 10. Re: [jBPM4] Synchronous process execution
                            Ronald van Kuijk Master

                            you call it a process, I call it a micro-flow... or orchestration or... what's in a name. You could also you bpel or something else for this.

                            From a nice article:

                            I already have a service execution pipeline, why do I need additional service orchestration mechanisms?

                            It might seem that that there is a lot of overlap between a service pipeline and service orchestration. In a nutshell, a service pipeline is a sequential orchestration of actions. The things that it does not support well, but are common orchestration requirements, are decisions, conditional transitions and parallel execution. Although technically you can do a lot these things as part of pipeline definition, it's not always easy. Our preference is to use a service pipeline for bringing together basic business functionality and additional infrastructure support, including data transformation, execution monitoring, etc and use jBPM for orchestration of these services.

                            Additional consideration for this choice can be deployment requirements. If the same action(s) is used in a lot of cases, it might make sense to separate it (them) into a separate service so that it will be deployed only once and use jBPM for orchestration.


                            The full article is an interesting read, but yes, it still is debatable.