1 2 3 Previous Next 38 Replies Latest reply on Aug 3, 2011 2:44 PM by Daniele Ulrich

    In memory TaskClient without Mina or JMS

    Gergely Dombi Newbie

      Hi,

       

      We are evaluating jBPM5 to be the backing workflow engine in our current project.

      Previously we have implemented a number of successful projects with the jBPM3 stack.

      First impressions with jBPM5 is pretty good however I have some questions about the Human Task management.

       

      My understanding on this topic is, tha it is assumed that the web application and the workflow engine

      is two separate applications, thus the client needs to communicate via Socket (Mina) or JMS.

      In our application it is not the case (and neither was in my past experience).

      We have a single binary web application (distributed as a war file) with the workflow engine, and the

      workflow client (the web UI) running in the same VM (same webapp by the way).

       

      Is there a way to implement such a solution that enables the client to manually (that is via API call)

      set some process variables,  specifiy a transition and signal the engine? I mean, without the

      async(-like) mechanism provided by default.

        • 1. In memory TaskClient without Mina or JMS
          Mauricio Salatino Master

          Hi there,

          yes jBPM5 provides this mechanism for flexibility, the old jBPM3 implementation provides a very simple lifecycle. jBPM5 provides an implementation of the WS-HT specification that provides a real life and standard life cycle management for your human tasks. We are working right now to provide a way to deploy the human task service as a service inside your servlet container or your application server.

          Greetings.

          • 2. In memory TaskClient without Mina or JMS
            Gergely Dombi Newbie

            Thanks for the reply Mauricio! If we can help in any way please let me know. Is there a JIRA issue for this feature where we could

            start with?

            • 3. In memory TaskClient without Mina or JMS
              Mauricio Salatino Master

              Are you willing to use a separate war module for the human task service?

              I have some work done, but not pushed to the repository yet. I can speed up the development if you are willing to use that option.


              Greetings.

              • 4. In memory TaskClient without Mina or JMS
                Gergely Dombi Newbie

                Our application is a stand alone war file (a spring + wicket based application). My first idea was to start with the old jBPM3 stack

                because we have jBPM3 knowledge. Then I evaluated jBPM5 and liked it pretty much. Moreover it seemed that this will be the

                supported product in the near future.

                 

                So our current approach is to start up the the jBPM knowledgebase and the Human Task Service in a servlet context listener , and

                use it from our service layer. A typical page flow:

                 

                1. The user retrieves a Task list from the engine (the list of probably persisted process instances, where the current user is the potential ownner of the actual task)

                2. The user selects (claims) a task

                3. We generate a wicket form based on the process varibles (and relating domain entities)

                4. The user specifies some input, and selects the next transition (this will be a generated button bar with the available transitions)

                5. The submit button's event handler signals the process instance with the specified transition

                 

                At least this is how I would do it with jBPM3 TaskManagement API.

                My understanding is that with the current methods, I have to create a TaskServer and KnowledgeBase instance in the ServletContextListener, cache a TaskClient in the user's session and use it to interact with the TaskServer.

                The only downside is that we have to use a socket server or JMS to achieve this. I would be quite happy with a non-standard (that is non WS-HT

                like) solution, that enables us to interact with the TaskServer in a blocking way (in VM API calls).

                • 5. In memory TaskClient without Mina or JMS
                  Kris Verlaenen Master

                  I see where you're going with this.  I assume you want to avoid using a loose coupling between the process engine and the human task service, but rather embed the service so you can call it directly?   I don't see any problem with this basically, what about just registering your own LocalWSHumanTaskHandler that doesn't use a local client but simply starts a server instance locally and instead of calling methods on the client calling the corresponding message on the server directly.

                   

                  You could create a task session in your handler and cache this:

                   

                          EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");

                          TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());

                          TaskServiceSession taskSession = taskService.createSession();

                   

                  And then modify WSHumanTaskHandler to call the taskSession instead of the taskClient whenever appropriate.

                   

                  I can see how this would be useful for other people as well, so if this actually works, let me know and I'll add it to the codebase   Or if my explanation doesn't make sense, let me know and I'll try to help.

                   

                  Kris

                  • 6. In memory TaskClient without Mina or JMS
                    Mauricio Salatino Master

                    I'm working on the module 6 of the jBPM5 community training(http://salaboy.wordpress.com/2011/01/24/announcing-jbpm5-community-training/)it will contain an example about the different ways of interaction withthe Human Task Server.

                    Greetings

                    • 7. In memory TaskClient without Mina or JMS
                      Gergely Dombi Newbie

                      Thanks guys I will give it a try, and post my experiences back here. Hopefully my work will be useful for others.

                      • 8. In memory TaskClient without Mina or JMS
                        Marie MM Newbie

                        Thank you very much for this details. I am using it and it works great. And it is very easy to change existing examples (instead of 'client', use 'taskSession').

                         

                        Is there any drawback of using this solution? I would expect this to be the default solution, since it is how it is to understand and it worked in similar way in previous version of jBPM. Of course, the possibility to extend it by various services is great.

                        • 9. Re: In memory TaskClient without Mina or JMS
                          Murali Mohan Rath Newbie

                          I am just starting with jbpm. I have exactly the same requirement. if you are able to use in memory taskclient, can you please share the code?

                          • 10. Re: In memory TaskClient without Mina or JMS
                            Mauricio Salatino Master

                            Hi Murali,

                            That's it:

                             

                                EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");

                                    TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());

                                    TaskServiceSession taskSession = taskService.createSession();

                             

                            Greetings.

                            • 13. In memory TaskClient without Mina or JMS
                              Marie MM Newbie

                              Hi,

                               

                              do you have any further experience with this solution?

                              It works fine, but when I deploy and run it on jBoss, it seems that it doesn't when I call ksession.startProcess(processId, params); and within it it runs into my workitem handler in which I have taskSession.addTask(newTask, taskParameters);

                               

                              It ends with exception You cannot commit during a managed transaction!

                              Did you get into similar problems?

                              2011-05-05 12:58:52,196 ERROR [org.hibernate.transaction.JDBCTransaction] (http-127.0.0.1-8080-2) JDBC commit failed

                              java.sql.SQLException: You cannot commit during a managed transaction!

                                  at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:659)

                                  at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:486)

                                  at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:170)

                                  at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:146)

                                  at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)

                                  at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:716)

                                  at org.jbpm.task.service.TaskServiceSession.addTask(TaskServiceSession.java:134)

                                  at com.company.wf.impl.jbpm.GeneralTaskHandler.executeWorkItem(GeneralTaskHandler.java:188)

                                  at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.internalExecuteWorkItem(JPAWorkItemManager.java:53)

                                  at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:101)

                                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)

                                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)

                                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:150)

                                  at org.jbpm.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)

                                  at org.jbpm.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)

                                  at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)

                                  at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35)

                                  at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:188)

                                  at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:302)

                                  at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:124)

                                  at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1099)

                                  at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:302)

                                  at org.drools.command.runtime.process.StartProcessCommand.execute(StartProcessCommand.java:119)

                                  at org.drools.command.runtime.process.StartProcessCommand.execute(StartProcessCommand.java:38)

                                  at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:295)

                                  at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:219)

                                  at com.compony.wf.impl.EngineImpl.startProcess(EngineImpl.java:231)

                                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                              Using Oracle and jBoss 5.1.0

                              • 14. In memory TaskClient without Mina or JMS
                                Marie MM Newbie

                                I managed to find out where and when exactly it goes down with JDBC commit failed java.sql.SQLException: You cannot commit during a managed transaction!

                                 

                                When the org.drools.persistence.jpa.processinstance.JPAWorkItemManager is called and then it calls some function in org.jbpm.task.service.TaskServiceSession which has doOperationInTransaction (with commit()).

                                 

                                In JPAWorkItemManager it calls

                                PersistenceContext context = ((PersistenceContextManager) env.get( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER )).getCommandScopedPersistenceContext();

                                which propably doesn't like when there is later tx.commit(); (tx is RESOURCE_LOCAL transition)

                                 

                                Any further insight?

                                1 2 3 Previous Next