1 Reply Latest reply on Feb 4, 2013 4:29 AM by Maciej Swiderski

    Perform DB operations from Workflow

    pns Newbie

      We have implemented JBPM Workflow in our application and is integrated with Spring MVC. Now we are planning to handle all the Workflow related DB operations from within the Workflow. We thought of two options.


      1) Define Script Task for invoking the DAO class to do the DB operations from the Workflow

      2) Define custom Service Task and invoke the DAO from the WorkItemHandler corresponding to the Service Task.


      We would like to get the opinion on this design approach to keep the Workflow related DB operations inside the Workflow, and also on the above two options. Which would be the right approach?

      If we go with the second one of having a Service Task, then we need to generalize the WorkItemHandler to be used in many situations, which would be slightly tricky.


      We would like to get the suggestion from JBPM experts.

      Thanks in advance...

        • 1. Re: Perform DB operations from Workflow
          Maciej Swiderski Master

          I would certainly recommend to go for option number 2. As it is much easier to maintain and you have an option to the the work in async way if that is needed. In script task you make your process definition really tightly coupled with the db operation code which is usually not good practice as it introduces rather difficult ways to manage that code.

          As it comes to making work item handler specific you could simply enclose all db specific code within that handler and configure it via parameters what it shall execute, either by supplying sql queries or sql script files that can differ between activities in the process.