Parallel activities within a EJB


EJB programming & troubleshooting: Parallel activities within a EJB

  1. Parallel activities within a EJB (2 messages)

    Hi ALL,

    I am developing a workflow engine in Java.

    Based on some condition, a activity needs to be executed. This is sequential. But there may be a situation where one activity may lead to execution of two or more activities in parallel, called a split. This split may recur in the form of a tree.
     How do we achieve from EJB? IS there any EJB pattern that can address this problem.

    Thanks in Advance.

    Deepa Nadig
  2. One common approach is using message-based communication to invoke the different activities.
    There are two ways to achieve parallelism using message-driven beans:
    1. Have the clients send a message to some topic, and for each activity that needs to take place, have a seperate MDB subscribe to that topic.
    2. Have different queues for each activity, and have the clients place a message in each of these queues.

    Which of the two suites you more depends on the nature of your application. In most respects these two strategies are quite similar. The first one may produce a little better decoupling, and the second one may be slightly more scalable.

  3. Unless you are trying to develop a workflow engine for the sake of selling it as a standalone commercial product (and actually, even in that case), you should take a look at ScenarioBeans. It's a JSP-like abstraction that enables a Java developer to easily program long-lived multi-step business processes and/or workflow. ScenarioBeans for orchestration logic is what JSP is for presentation logic.

    A ScenarioBean basically has the full power of Java and provides parallel execution of branches, sophisticated join patterns, event and exception handling, coordinating JMS and sync or async Web Services and much more. It uses four orchestration tags and takes about a day to master for an average Java developer.

    The execution environment is an orchestration container that provides all the services transparently to the Java developer which you'd normally expect a BPM or Workflow engine to provide. The container is based on J2EE and runs on top of WebLogic, etc.

    You can download the product from: