4 Replies Latest reply on Jan 14, 2010 6:09 PM by awolfard

    Exception Handling in node (v3.2)

      Hi all,

       

      Playing around with some jbpm code and I have a question regarding exception handling in a node.

      What I want is the following:

      When an exception occurs in my actionhandler I want to startup a task so a user can correct the process(-step) manually and signal the process again.

       

      I came with this:

       

      Node actionhandlers all extend the BaseNodeHandler:

       

      public abstract class BaseNodeHandler implements ActionHandler {

       

          public void execute(ExecutionContext executionContext) throws Exception {
              try {
                  String returnValue = this.doExecute(executionContext);
                  if (returnValue == null) {
                      executionContext.leaveNode();
                  } else {
                      executionContext.leaveNode(returnValue);
                  }
              } catch (Exception e) {
                  // Start up another process with a task (async tasknode) to deal with this situation?
                  // After manual correction give signal to continue processing?
              }
          }
         
          public abstract String doExecute(ExecutionContext executionContext) throws Exception;
      }

       

      When an exception occurs the node is not propagated (leaveNode is not called) and therefore the state of the process is persisted (right?)
      . Then I want to start up another process which creates a task (async tasknode) so a user can make some corrections.

       

      Is it okay to start another process in the exception block?

        • 1. Re: Exception Handling in node (v3.2)
          kukeltje
          • 2. Re: Exception Handling in node (v3.2)

            Hi Ronald,

             

            Thank you for your response and the link you gave me.

            But I think I am missing something because I cannot see how this link/page answers my question.

             

            My main question is, is it valid to start a separate process in my catch block of the ActionHandler?

            This new process has 1 task node (async) so a user can take some corrective action and later on signal the process to continue.

             

            With kind regards,

             

            Arnoud.

            • 3. Re: Exception Handling in node (v3.2)
              kukeltje

              Sorry, the article was about escalation, not exception.

               

              In the execute method a transaction is active, so I would not do long running things. If you want exceptions handled on a process level, I'd model those in the process as far as possible (since they have business consequences). What you could do is move set e.g. a processvariable with the name of that specific state, move the token to an 'exception handling task' and when finishing that task, move the token back to the original node.

              • 4. Re: Exception Handling in node (v3.2)

                Hi Ronald,

                 

                Thanks for the reply.

                 

                I am aware that the execute is done in a transaction; that's the reason I have an async tasknode in the proces to be started.

                I want to create a separate 'Generic Error Handling'-process for all processes; the exceptions I am talking about here are not Business Exceptions but real technical exceptions like 'Database is temporarly offline'.

                 

                That's why I do not want to model it in my proces.

                 

                Also if I model it in all my processes, I have to connect all nodes to the Generic Error Handling task.

                 

                Technically it is all working in my test environment but I wonder if Exception Handling like this is done before and if it feasable in production environments because I do not find much information about this topic (Exception Handling in JBPM) on the web.

                 

                Regards,

                 

                Arnoud.