3 Replies Latest reply on Apr 26, 2010 11:33 AM by Leo van den berg

    How to start a jbpm process asynchronously

    gdfgd eqwe Novice

      Hy!


      I' d like to start 20-30 jbpm process without this blocking the UI.


      My question is, how to start a jbpm process asynchronously?
      Is it possible with a seam 2.2.0GA application


      with the @Asynchronous annotation is also cause concurrent modification exception.

        • 1. Re: How to start a jbpm process asynchronously
          Leo van den berg Master

          Hi Kim,


          Use the raise asynchronous event in your bean and let the observing class start the processes. Works like a charm,


          Leo

          • 2. Re: How to start a jbpm process asynchronously
            gdfgd eqwe Novice

            It does not work.


            I think the jbpm process start should start with an available conversation, but raiseAsyncEvent works with request scope.

            • 3. Re: How to start a jbpm process asynchronously
              Leo van den berg Master

              Hi,


              I had the same problems in a combined EJB3/POJO environment. I stopped using the JBPM annotation because it gave too much problems. I directly use the JBPM api:


              As an example:




                   @Observer("es.esam.im4u.trafficIncidentEvent.startTask")
                   public void startIncidentManagement(TrafficIncident i, String actor) {
              
                              // Prepare the stuff and get the vars you need from the Async call
                        
                        try {
                             GraphSession gs = jbpmContext.getGraphSession();
                             ProcessDefinition def = gs.findLatestProcessDefinition("incidentManagement");
                                      // Put all the vars you need in the pi-vars
                             // Create a new ProcessInstance 
                             ProcessInstance pi = new ProcessInstance(def);
                             pi.getContextInstance().createVariable("location", location);
                             // Place the token right after the start node 
                             Token tkn = pi.getRootToken();
                             tkn.signal();
                             jbpmContext.save(pi);
                        } catch (Exception e){
                             log.error(e.getMessage());
                        }
                        
                   }