1 2 Previous Next 19 Replies Latest reply on May 28, 2010 1:32 AM by HuiSheng Xu

    SubProcess signaling issue

    Maciej Swiderski Master

      Hi guys,

       

      I have created jira issue that relates to potential problem/misuse of sub processes. Please have a look at it and let me know your opinion.

      https://jira.jboss.org/browse/JBPM-2874

       

      Thanks

        • 1. Re: SubProcess signaling issue
          HuiSheng Xu Master

          Hi Maceij,

           

          It is a very common problem when we use sub-process, because there is no way to get a sub-process from it's super-process.

           

          Consider about which of using is better:

           

          1.

          //

          // Is there any risk for a session already closed exception?

          //

          ProcesssInstance subProcessInstance = execution.getSubProcessInstance();

          if (subProcessInstance != null) {

            executionService.signalExecutionById(subProcessInstance.getId());
          }.

           

          2.

          String subProcessInstanceId = execution.getSubProcessInstanceId();

          if (subProcessInstanceId != null) {

              executionService.signalExecutionById(subProcessInstanceId);
          }

           

          3.

          if (execution.hasSubProcessInstance()) {

            executionService.signalExecutionById(execution.getSubProcessInstanceId());
          }

           

          4.

          // Don't like this way, need to add too much methods in API.

          executionService.signalSubProcessInstance(executionId);

          • 2. Re: SubProcess signaling issue
            Maciej Swiderski Master

            Hi HuiSheng,

             

            thanks for your comment.

             

            I would go for option 1 (in fact has already tested that and it seems to work properly for signaling). Another thing is to keep the approuch consistent since we expose main process instance as Execution I would say we shall give same type for sub process instance.

             

            Another question was about securing SubProcessActivity to do not signal it while sub process is still active. I did a small fix that throws an exception when user tries to signal sub process while it is not finished. Do you think it is right way to do?

            • 3. Re: SubProcess signaling issue
              HuiSheng Xu Master

              Hi Maciej,

               

              Get an exception for signaling a waiting super-process would be nice.  But I don't know why there is no state for this scenario?  If there is a particular state for waiting super-process, then we needn't to throw an exception by hand.

               

              Could we set super-process to 'inactive-scope' state?

              • 4. Re: SubProcess signaling issue
                Maciej Swiderski Master

                you mean that when we enter sub process the main process should be in state inactive-scope?

                 

                If so, I am afraid it won't work as expected, I really liked the idea though.

                The reason of this is if you mark main execution as inactive-scope when sub process activity is executed then automatic signal after sub process ends will fail since checkActive is executed in end activity which is prior to signal of sub process activity.

                Of course end activity code can be modified as well but I don't think it is a good idea.

                 

                In my opinion engine should prevent of signaling main process while sub process is active, otherwise we could end up in really weird situations where some of the executions are left and main process is finished.

                • 5. Re: SubProcess signaling issue
                  HuiSheng Xu Master

                  Hi Maciej,

                   

                  Yes, you are right for the inactive-scope.  But we still have no way to find whether the super-process has active state sub process.  Maybe could decide by this?

                   

                  if (execution.getSubProcessInstance() != null)

                  • 6. Re: SubProcess signaling issue
                    Maciej Swiderski Master

                    As I understand this, sub process must contain an end activity to be able to signal main process to move on.

                    So my idea was to check in signal method of SubProcessActivity if sub process instance is in state ended, if so signaling is allowed otherwise throw an exception.

                    • 7. Re: SubProcess signaling issue
                      HuiSheng Xu Master

                      Hi Maciej,

                       

                      There is an issue for what you said.  Please refer this https://jira.jboss.org/browse/JBPM-2856.


                      In my opinion,  when a sub process ended, we should delete it and signal the super process.  So there will be no process with ended state in database.  If you cannot find a process intance, it means that it has already ended.

                      • 8. Re: SubProcess signaling issue
                        Maciej Swiderski Master

                        It looks like we are talking about two different things

                         

                        What I am trying to say is that I would like to ensure that signalExecutionById(mainProcessId) will not signal running but not yet finished sub process. At the moment when your process has a sub process in a wait state and you signal as above then will signal sub process activity regardless of the state it currently is. Result of it will be:

                        - main process will move on

                        - sub process will be left unfinished - end method will not be invoked and this execution will not be deleted

                         

                        My suggestion is to prevent of signaling sub process activity when it is running. You don't need to fetch it from db since when signal method is executed you have access to both main and sub process instances.

                        Will attach a patch today to jira.

                        • 9. Re: SubProcess signaling issue
                          HuiSheng Xu Master

                          Hi Maciej,

                           

                          Waiting for you patch.  I believe we could agree with each other in the end.

                          • 10. Re: SubProcess signaling issue
                            Maciej Swiderski Master

                            Patch uploaded to jira. Please let me know what do you think about it.

                            • 11. Re: SubProcess signaling issue
                              HuiSheng Xu Master

                              Hi Maciej,

                               

                              I had understood what's your mean.  Yes,  The checkActive() method should check subProcessInstance's state.

                               

                              And I think here returns 'ProcessInstance' type may be better.

                              Execution getSubProcessInstance();
                              
                              
                              

                               

                              Do you have any idea?

                              • 12. Re: SubProcess signaling issue
                                Maciej Swiderski Master

                                HuiSheng Xu wrote:


                                And I think here returns 'ProcessInstance' type may be better.

                                Execution getSubProcessInstance();
                                

                                I followed the same convention as for other methods, for instance getprocessInstance and getParent.

                                • 13. Re: SubProcess signaling issue
                                  HuiSheng Xu Master

                                  Hi Maciej,

                                   

                                  I understand why getParent() return Execution, because a splited execution could has sub process instance.

                                   

                                  I cannot understand why getProcessInstance() has to return Execution, it should return process instance by its meaning. And ProcessInstance is extends from Execution, it has all method declarations of Execution.  Return ProcessInstance is more clearly, and won't effect any Backward  compatibility.

                                   

                                  Do you have any idea about this?

                                  • 14. Re: SubProcess signaling issue
                                    Maciej Swiderski Master

                                    HuiSheng Xu wrote:

                                     

                                    I understand why getParent() return Execution, because a splited execution could has sub process instance.

                                     

                                    But SubProcessInstance can have another subprocessInstance as well, doesn't it?

                                    1 2 Previous Next