0 Replies Latest reply on Jan 9, 2013 7:57 AM by Jonathan Albornoz

    Urgent, Mina Handler is not working

    Jonathan Albornoz Newbie

      Hi, i have configure my jbpm 53 with jboss 7.0.2 and the persistence is with oracle, all work fine in the console, but i have to make it work with the api.

      I have the next code to start my proces and complete it! but when the task is complete, the handler not work, and dont reserve the next node.

      I imagine that my handler is not used correctly. Any idea what is my problem in the code?? i use jbpm helper, that is configures in the jbpm-test in the runtime folder.

      i dont know if mina is correctly used, neither if i must use hornetq, or anything else!!

      I tried with jbpm 5.4 and i have the same problem...any please...this is very urgent!!

      the files that i have is attached!! thanks!! please!!!

       

       

      package com.sample;

      import java.util.List;

      import javax.persistence.EntityManagerFactory;

      import javax.persistence.Persistence;

      import org.drools.KnowledgeBase;

      import org.drools.SystemEventListenerFactory;

      import org.drools.builder.KnowledgeBuilder;

      import org.drools.builder.KnowledgeBuilderFactory;

      import org.drools.builder.ResourceType;

      import org.drools.io.ResourceFactory;

      import org.drools.logger.KnowledgeRuntimeLogger;

      import org.drools.logger.KnowledgeRuntimeLoggerFactory;

      import org.drools.runtime.StatefulKnowledgeSession;

      import org.jbpm.process.workitem.wsht.HornetQHTWorkItemHandler;

      import org.jbpm.task.TaskService;

      import org.jbpm.task.query.TaskSummary;

      import org.jbpm.task.service.SyncTaskServiceWrapper;

      import org.jbpm.task.service.TaskClient;

      import org.jbpm.task.service.hornetq.AsyncHornetQTaskClient;

      import org.jbpm.task.service.mina.MinaTaskClientConnector;

      import org.jbpm.task.service.mina.MinaTaskClientHandler;

      import org.jbpm.task.service.mina.MinaTaskServer;

      import org.jbpm.task.service.responsehandlers.BlockingTaskOperationResponseHandler;

      import org.jbpm.task.service.responsehandlers.BlockingTaskSummaryResponseHandler;

      import org.jbpm.test.JBPMHelper;

       

      public class ProcessMain2 {

       

                public static final void main(String[] args) throws Exception {

                          startUp();

                          // load up the knowledge base

                          KnowledgeBase kbase = readKnowledgeBase();

                          StatefulKnowledgeSession ksession = JBPMHelper.newStatefulKnowledgeSession(kbase);

                          // start a new process instance

                          ksession.startProcess("com.sample.bpmn.hello");

                          //ksession.dispose();

                          System.out.println("Process started ...");

       

                          //Genero la conexion para acceder a las tareas usando TASK

                          TaskClient client = new TaskClient(new MinaTaskClientConnector("client 1",

                          new  MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

                          client.connect("127.0.0.1", 9123);

        //capturo las tareas reservadas

                          BlockingTaskSummaryResponseHandler taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler();

                          client.getTasksAssignedAsPotentialOwner("luis", "en-UK", taskSummaryResponseHandler);

                          List<TaskSummary> tasks = taskSummaryResponseHandler.getResults();

                          for (TaskSummary task: tasks) {

                                    System.out.println(task.getId() + " " + task.getName() + " " + task.getStatus());

                          }

                          //para todas las tareas incluyendo las terminadas

                          taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler();

                          System.out.println("***************************************************");

                          client.getTasksOwned("luis", "en-UK", taskSummaryResponseHandler);

                          tasks = taskSummaryResponseHandler.getResults();

                          for (TaskSummary task: tasks) {

                                    System.out.println(task.getId() + " " + task.getName() + " " + task.getStatus());

                          }

        //para iniciar una tarea

                          BlockingTaskOperationResponseHandler responseHandler =  new BlockingTaskOperationResponseHandler();

                          client.start( 18, "luis", responseHandler );

                          responseHandler.waitTillDone(1000);

                          //para completar una tarea

                          responseHandler = new BlockingTaskOperationResponseHandler();

                          client.complete( 18, "luis", null , responseHandler);

                          responseHandler.waitTillDone(1000);

                          ksession.dispose();

                          System.exit(0);

                }

        private static KnowledgeBase readKnowledgeBase() throws Exception {

                          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

                          kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);

                          return kbuilder.newKnowledgeBase();

                }

       

                private static void startUp() {

                          JBPMHelper.startH2Server();

                          JBPMHelper.setupDataSource();

        JBPMHelper.startTaskService();

                }

          

      }