1 Reply Latest reply on Sep 2, 2014 7:46 AM by mdegan

    Problems with jBPM 5.4 with concurrent users

    Shobhit Tyagi Master

      Hello all,

       

      I am facing a problem with stressing my jBPM 5.4 application with a load runner.

       

      The details are below. Any kind of help will be highly appreciated. Thanks a million.

       

      The request comes from an

      EJB Stateless bean and a remote call is made to another EJB Stateless bean which calls the BPM API.

       

      The first few requests are created perfectly fine with no problem what so ever.

       

      The next few requests end up with the error below repeatedly :

       

      HornetQException[errorCode=102 message=Session is closed]

            at org.hornetq.core.client.impl.ClientSessionImpl.checkClosed(ClientSessionImpl.java:1881)

            at org.hornetq.core.client.impl.ClientSessionImpl.internalCreateConsumer(ClientSessionImpl.java:1782)

            at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:478)

            at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:444)

            at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:413)

            at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:418)

            at org.hornetq.core.client.impl.DelegatingSession.createConsumer(DelegatingSession.java:232)

            at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:106)

            at java.lang.Thread.run(Thread.java:770)

       

       

       

      The next requests throw the following exceptions :

       

      1. java.lang.RuntimeException: Task operation request timed out

            at org.jbpm.task.service.SyncTaskServiceWrapper.addTask(SyncTaskServiceWrapper.java:118)

            at org.jbpm.process.workitem.wsht.GenericHTWorkItemHandler.executeWorkItem(GenericHTWorkItemHandler.java:182)

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

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

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

            at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:279)

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

            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:126)

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

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

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

            at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:170)

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

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

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

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

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

            at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)

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

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

            at pe.com.bcp.acma.bpm.model.BpmAPI.initiateProcess(BpmAPI.java:134)

            at pe.com.bcp.acma.bpm.services.BpmComunEJB.iniciarProceso(BpmComunEJB.java:79)

            at pe.com.bcp.acma.bpm.services.EJSLocalNSLBpmComunEJB_ae19d5f6.iniciarProceso(EJSLocalNSLBpmComunEJB_ae19d5f6.java)

            at pe.com.bcp.acma.bpm.impl.FachadaBPMImpl.iniciarProceso(FachadaBPMImpl.java:48)

            at pe.com.bcp.acma.bpm.facade.EJSRemote0SLFachadaBPMImpl_bc73e36a.iniciarProceso(EJSRemote0SLFachadaBPMImpl_bc73e36a.java)

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

            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

            at java.lang.reflect.Method.invoke(Method.java:611)

            at com.ibm.rmi.util.ProxyUtil$4.run(ProxyUtil.java:609)

            at java.security.AccessController.doPrivileged(AccessController.java:280)

            at com.ibm.rmi.util.ProxyUtil.invokeWithClassLoaders(ProxyUtil.java:606)

            at com.ibm.CORBA.iiop.ClientDelegate.invoke(ClientDelegate.java:1177)

            at $Proxy226.iniciarProceso(Unknown Source)

            at pe.com.bcp.acma.bpm.facade._BpmFachadaRemoto_Stub.iniciarProceso(_BpmFachadaRemoto_Stub.java:1)

            at pe.com.bcp.acma.modelo.negocio.SolicitudEJB.iniciarFlujoCreditoEfectivo(SolicitudEJB.java:268)

            at pe.com.bcp.acma.modelo.negocio.SolicitudEJB.grabarRegistroSolicitud(SolicitudEJB.java:165)

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

            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

            at java.lang.reflect.Method.invoke(Method.java:611)

            at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:6304)

            at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:568)

            at org.apache.webbeans.ejb.common.interceptor.OpenWebBeansEjbInterceptor.callInterceptorsAndDecorators(OpenWebBeansEjbInterceptor.java:521)

            at org.apache.webbeans.ejb.common.interceptor.OpenWebBeansEjbInterceptor.callToOwbInterceptors(OpenWebBeansEjbInterceptor.java:199)

            at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

            at java.lang.reflect.Method.invoke(Method.java:611)

            at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227)

            at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:548)

            at org.apache.webbeans.ejb.WSEJBInterceptor.callToOwbInterceptors(WSEJBInterceptor.java:121)

            at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

            at java.lang.reflect.Method.invoke(Method.java:611)

            at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227)

            at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:548)

            at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInvoke(InvocationContextImpl.java:229)

            at com.ibm.ejs.container.EJSContainer.invoke(EJSContainer.java:6195)

            at pe.com.bcp.acma.modelo.negocio.EJSLocalNSLSolicitudEJB_51b7bb76.grabarRegistroSolicitud(EJSLocalNSLSolicitudEJB_51b7bb76.java)

            at pe.com.bcp.acma.modelo.implement.ModeloFachadaImpl.grabarRegistroSolicitud(ModeloFachadaImpl.java:191)

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

            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

            at java.lang.reflect.Method.invoke(Method.java:611)

            at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:6304)

            at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:568)

            at org.apache.webbeans.intercept.InvocationContextImpl.proceedAroundInvokes(InvocationContextImpl.java:266)

            at org.apache.webbeans.intercept.InvocationContextImpl.proceed(InvocationContextImpl.java:175)

            at pe.com.bcp.acma.cdi.modelo.interceptor.LoggingInterceptor.aroundInvoke(LoggingInterceptor.java:33)

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

            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

            at java.lang.reflect.Method.invoke(Method.java:611)

            at org.apache.webbeans.intercept.InvocationContextImpl.proceedAroundInvokes(InvocationContextImpl.java:237)

            at org.apache.webbeans.intercept.InvocationContextImpl.proceed(InvocationContextImpl.java:175)

            at pe.com.bcp.acma.cdi.modelo.interceptor.AuditInterceptor.aroundInvoke(AuditInterceptor.java:43)

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

            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

            at java.lang.reflect.Method.invoke(Method.java:611)

            at org.apache.webbeans.intercept.InvocationContextImpl.proceedAroundInvokes(InvocationContextImpl.java:237)

            at org.apache.webbeans.intercept.InvocationContextImpl.proceed(InvocationContextImpl.java:175)

            at org.apache.webbeans.intercept.InterceptorUtil.callAroundInvokes(InterceptorUtil.java:625)

            at org.apache.webbeans.ejb.common.interceptor.OpenWebBeansEjbInterceptor.callInterceptorsAndDecorators(OpenWebBeansEjbInterceptor.java:559)

            at org.apache.webbeans.ejb.common.interceptor.OpenWebBeansEjbInterceptor.callToOwbInterceptors(OpenWebBeansEjbInterceptor.java:199)

            at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

            at java.lang.reflect.Method.invoke(Method.java:611)

            at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227)

            at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:548)

            at org.apache.webbeans.ejb.WSEJBInterceptor.callToOwbInterceptors(WSEJBInterceptor.java:121)

            at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

            at java.lang.reflect.Method.invoke(Method.java:611)

            at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227)

            at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:548)

            at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInvoke(InvocationContextImpl.java:229)

            at com.ibm.ejs.container.EJSContainer.invoke(EJSContainer.java:6195)

            at pe.com.bcp.acma.modelo.facade.EJSLocal0SLModeloFachadaImpl_bf5759e4.grabarRegistroSolicitud(EJSLocal0SLModeloFachadaImpl_bf5759e4.java)

            at pe.com.bcp.acma.modelo.beans.SolicitudMBean.guardarRegistroSolicitud(SolicitudMBean.java:409)

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

            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

            at java.lang.reflect.Method.invoke(Method.java:611)

            at org.apache.el.parser.AstValue.invoke(AstValue.java:266)

            at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)

            at org.apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:83)

            at javax.faces.component._MethodExpressionToMethodBinding.invoke(_MethodExpressionToMethodBinding.java:88)

            at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:100)

            at javax.faces.component.UICommand.broadcast(UICommand.java:120)

            at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:973)

            at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:275)

            at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1285)

            at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:711)

            at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:34)

            at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)

            at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

            at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)

            at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1214)

            at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)

            at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)

            at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)

            at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125)

            at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:92)

            at pe.com.bcp.acma.webutil.session.NoCacheFilter.doFilter(NoCacheFilter.java:53)

            at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)

            at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)

            at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:926)

            at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1023)

            at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)

            at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:895)

            at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)

            at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)

            at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)

            at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:522)

            at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:311)

            at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:87)

            at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)

            at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)

            at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)

            at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)

            at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)

            at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)

            at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)

            at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1783)

       

      The API used in starting the process is :

       

            public long initiateProcess(final String processDefId, final Map<String, Object> parametros,

                        final List<String> arlProcessName) throws BpmException{

                  long processInstId = 0;

                  try {

                        ProcessInstance processInstance = null;

                        StatefulKnowledgeSession kSession = BpmRepositoryConfig.createSession(arlProcessName);

                        taskHandler = new HornetQHTWorkItemHandler(kSession);

                        taskHandler.setIpAddress(ipAddress);

                        taskHandler.setPort(port);

                        taskHandler.setConnectorName(new StringBuffer("TaskHandler").append(UUID.randomUUID()).toString());

                        kSession.getWorkItemManager().registerWorkItemHandler(BpmConstantes.TASK_HANDLER_NAME, taskHandler);

                        final JPAWorkingMemoryDbLogger jpaDBlogger = new JPAWorkingMemoryDbLogger(kSession);

                        processInstance = kSession.startProcess(processDefId, parametros);

                        if (processInstance != null) {

                              processInstId = processInstance.getId();

                        }

                        System.out.println("Process Started with ID : "+processInstId);

                        kSession.fireAllRules();

                        if (taskHandler.isConnected()) {                     

                                    taskHandler.dispose();                   

                        }

                        /* Cerrar las conexiones */

                        jpaDBlogger.dispose();

                  } catch (Exception e) {

                        throw new BpmException(e.getMessage());

                  }

                  System.out.println("Exiting Method Initiate Process");

                  return processInstId;

            }

       

      1. BpmRepositoryConfig.createSession

       

      public static StatefulKnowledgeSession createSession(final List<String> arlProcessName) {

                  readKnowledgeBase(arlProcessName);

                  final EntityManagerFactory entityMF = Persistence

                              .createEntityManagerFactory(BpmConstantes.JBPM_PERSISTENCE_NAME);

                  final Environment enviroment = KnowledgeBaseFactory.newEnvironment();

                  enviroment.set(EnvironmentName.ENTITY_MANAGER_FACTORY, entityMF);

                  enviroment.set(EnvironmentName.GLOBALS, new MapGlobalResolver());

       

                  final Properties properties = new Properties();

                  properties.put(BpmConstantes.JBPM_MANAGER_FACTORY, BpmConstantes.JBPM_JPAMANAGER_FACTORY);

                  properties.put(BpmConstantes.JBPM_SIGNAL_FACTORY, BpmConstantes.JBPM_SIGNALMANAGER_FACTORY);

                  final KnowledgeSessionConfiguration kconfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);

                  return JPAKnowledgeService.newStatefulKnowledgeSession(kBase, kconfig, enviroment);

            }

       

      readKnowledgeBase

                     

                      public static void readKnowledgeBase(final List<String> arlProcessName) {

                  if (TextUtil.esNulo(kBase)) {

                        ProcessBuilderFactory.setProcessBuilderFactoryService(new ProcessBuilderFactoryServiceImpl());

                        ProcessMarshallerFactory.setProcessMarshallerFactoryService(new ProcessMarshallerFactoryServiceImpl());

                        ProcessRuntimeFactory.setProcessRuntimeFactoryService(new ProcessRuntimeFactoryServiceImpl());

                        BPMN2ProcessFactory.setBPMN2ProcessProvider(new BPMN2ProcessProviderImpl());

                        final KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

                        StringBuffer result;

                        for (String process : arlProcessName) {

                              result = nuevoBuffer();

                              result.append(process).append(BpmConstantes.PROC_DEF_EXT);

                              kBuilder.add(ResourceFactory.newClassPathResource(result.toString()), ResourceType.BPMN2);

                        }

                        kBase = kBuilder.newKnowledgeBase();

                  }

            }

       

       

       

      Other than all of this. I must add that we are not using Bitronix transaction manager, which is default by jBPM. We use the Transaction manager of Websphere.

        • 1. Re: Problems with jBPM 5.4 with concurrent users
          mdegan Newbie

          Hi Shobhit,

           

          Try removing the JPAWorkingMemoryDBLogger from the sessions. Since there is new instance of knowledge sessions that you are creating, each on of them might be running in separate threads and when they try to log events into the DB, one thread might lock the rows/tables preventing the other thread from accessing it creating a deadlock situation. With this delay, it might cause a closure of the session for the task service as well.

           

          Please check Chapter 6. Core Engine: Basics, section: 6.8.7.3. Multiple knowledge sessions and persistence      

           

          Regards,

          Manny