pushpak1981 [https://community.jboss.org/people/pushpak1981] created the discussion
"Re: jBPM5 Database Exception" To view the discussion, visit: https://community.jboss.org/message/732912#732912 -------------------------------------------------------------- Hi Maciej, We are using multiple CommandBasedStatefulSession with Asynchronous Interceptor to execute the processes. Please find below the sample code: > @org.junit.Test > public void testProcessFlow2() throws Exception > { > EntityManagerFactory emf = Persistence.createEntityManagerFactory( > "org.jbpm.persistence.jpa" ); > > Environment env = KnowledgeBaseFactory.newEnvironment(); > > env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf ); > > InitialContext ctx = new InitialContext(); > > KnowledgeBuilder builder = > KnowledgeBuilderFactory.newKnowledgeBuilder(); > > builder.add(ResourceFactory.newClassPathResource("HumanTaskTest.bpmn"), > ResourceType.BPMN2); > builder.add(ResourceFactory.newClassPathResource("UnitTest1.bpmn"), > ResourceType.BPMN2); > > KnowledgeBase kbase = builder.newKnowledgeBase(); > > CommandBasedStatefulKnowledgeSession ksession1 = > (CommandBasedStatefulKnowledgeSession)JPAKnowledgeService.newStatefulKnowledgeSession( > kbase, null, env ); > CommandBasedStatefulKnowledgeSession ksession2 = > (CommandBasedStatefulKnowledgeSession)JPAKnowledgeService.newStatefulKnowledgeSession( > kbase, null, env ); > > JPAWorkingMemoryDbLogger logger = new > JPAWorkingMemoryDbLogger(ksession1); > JPAWorkingMemoryDbLogger logger2 = new > JPAWorkingMemoryDbLogger(ksession2); > > CommandBasedWSHumanTaskHandler task = new > CommandBasedWSHumanTaskHandler(ksession1); > CommandBasedWSHumanTaskHandler task1 = new > CommandBasedWSHumanTaskHandler(ksession2); > > ksession1.getWorkItemManager().registerWorkItemHandler("Human Task", > task); > ksession2.getWorkItemManager().registerWorkItemHandler("Human Task", > task1); > > AsynchronousInterceptor it1 = new AsynchronousInterceptor(); > AsynchronousInterceptor it2 = new AsynchronousInterceptor(); > > > StartProcessCommand start = new > StartProcessCommand("com.test.humanTask"); > StartProcessCommand start1 = new > StartProcessCommand("com.test.UnitTest1"); > > Map<String,Object> map = new HashMap<String, Object>(); > map.put("i", new Integer(53)); > > start1.setParameters(map); > > ksession1.addInterceptor(it1); > ksession2.addInterceptor(it2); > > ksession1.execute(start1); > ksession2.execute(start1); > > Thread.currentThread().sleep(20000); > } Thanks. -------------------------------------------------------------- Reply to this message by going to Community [https://community.jboss.org/message/732912#732912] Start a new discussion in jBPM at Community [https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
_______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
