3 Replies Latest reply on Jul 25, 2006 2:07 PM by kukeltje

    How to dispatch workflows/create an event handler loop?

    ryhadley

      When I think of what a workflow engine does, it is essentially an event handler loop that is configured to appropriately dispatch the incoming messages:

      event loop
       get message from queue
       handle message by one of:
       - start new workflow, or
       - start next activity in a (suspended) workflow
      repeat



      Based on the user guide http://docs.jboss.org/jbpm/v3/userguide/index.html, I can see how to define a workflow (as XML) and give the code behind the activities in the workflow (implement ActionHandler interface), but I don't understand how jBPM takes incoming "messages" and dispatches to the appropriate ActionHandlers. i.e. The user guide only has code snippets that are JUnit tests which create a workflow from an XML definition (ProcessDefinition.parseXmlString()) and then execute the workflow by pushing the token through it with token.signal() (i.e. 3.2. Database example in User Guide); there is no practical code example for a workflow application.

      Does jBPM provide such an event loop/dispatch capability? Or do I need to figure out how to implement this myself (using something like the code in ProcessInstanceBean.java, from the webapp example, and tie it into the Scheduler from chapter 12 in the User Guide)? If so, is there a simple example available?

      Thanks.

        • 1. Re: How to dispatch workflows/create an event handler loop?
          kukeltje

          jBPM has the commandExecutor which can do most of what you want (AFAIK). It can be either simple (db based) or JMS based. Look at the docs, examples and testcases

          • 2. Re: How to dispatch workflows/create an event handler loop?
            ryhadley

            In the user guide, both "Chapter 9. Process Modelling" and "Chapter 13. Asynchronous continuations" talk at a very high/abstract level and only briefly mention CommandExecutorThread. (And the JavaDocs for these classes are empty). So, in theory, it sounds like jBPM does what I want, but I can't find any specifics on how to go about implementing a solution in practice.

            Is there any example of code for how to use the CommandExecutorThread? i.e. If I wanted a very simple program that just started a CommandExecutorThread and responded to messages by invoking the correct workflow, what would I put in the main() method to (fully) configure and start the CommandExecutorThread?

            Thanks.

            • 3. Re: How to dispatch workflows/create an event handler loop?
              kukeltje

              in my previous response I mention the examples and testcases, so yes there are. Testcases are normally in the sourcecode, so that is at least what you need. I personnaly do not know the advances/changes between 3.1.x and the yet unreleaseed 3.2. In the 3.2 there is also an example using async continuations but I think it is based on jms