5 Replies Latest reply on Dec 29, 2011 5:08 AM by Mauricio Salatino

    StatefulKnowledgeSessionImpl Serializable

    Donald Walters Newbie

      Hello Friends,


      Happy Holidays!


      I am trying to to implement a cluster in my application, using Hazelcast. The issue is that the sessions need to be available to all nodes. Currently the sessions are stored in a Map but once I put the Hazelcast codes I get and exception. It is pretty simple, StatefulKnowledgeSessionImpl is not serializable. How can I get this wot work or make it serializable?




        • 1. Re: StatefulKnowledgeSessionImpl Serializable
          Mauricio Salatino Master

          To serialize(externalize) the session status we use the persistence-jpa module from drools and jbpm. You can put inside hazelcast those binary serialized objects there.

          You need to remember that now everything that you insert inside the ksession must be serializable. You can check also the variable persistence strategies.


          • 2. Re: StatefulKnowledgeSessionImpl Serializable
            Donald Walters Newbie

            But if I use the JPA module then I will start getting the issues that i had previously. Do I have to use the EMF? I just want to be able to serialize the Map that contain the sessions.

            • 3. Re: StatefulKnowledgeSessionImpl Serializable
              Mauricio Salatino Master

              If you don't want to use the persistence module you will need to externalize the objects that are inside the StatefulKnowledgeSessionImpl object in the same way that the persistence module is doing that. Take a look at the jbpm-persistence-jpa module. Notice that the jbpm-persistence-jpa module also support another ways of persistence like for example a Map.



              • 4. Re: StatefulKnowledgeSessionImpl Serializable
                Donald Walters Newbie

                I made the change to use the MapBasedPersistence with the underlying Map coming from Hazelcast. That seems to work but sometimes I get the following error. I am not sure how that happens but it does when i try to resume a session. I a try the resume a second time it goes through without issue.


                [2011-12-29 00:00:10.769] DEBUG [58] com.test.jbpm.KnowledgeSessionStore - saving session info org.drools.persistence.info.SessionInfo@59961a07

                [2011-12-29 00:00:10.798] ERROR [313] org.drools.persistence.SingleSessionCommandService - Could not commit session


                          at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.setState(WorkflowProcessInstanceImpl.java:251)

                          at org.jbpm.marshalling.impl.AbstractProcessInstanceMarshaller.readProcessInstance(AbstractProcessInstanceMarshaller.java:382)

                          at org.jbpm.persistence.processinstance.ProcessInstanceInfo.getProcessInstance(ProcessInstanceInfo.java:134)

                          at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:64)

                          at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:190)

                          at org.drools.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1113)

                          at org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:283)

                          at org.jbpm.persistence.processinstance.JPASignalManager.signalEvent(JPASignalManager.java:24)

                          at org.jbpm.process.instance.ProcessRuntimeImpl.signalEvent(ProcessRuntimeImpl.java:355)

                          at org.drools.impl.StatefulKnowledgeSessionImpl.signalEvent(StatefulKnowledgeSessionImpl.java:321)

                          at org.drools.command.runtime.process.SignalEventCommand.execute(SignalEventCommand.java:91)

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

                          at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.signalEvent(CommandBasedStatefulKnowledgeSession.java:200)

                          at com.test.platform.jbpm.ExecutionController.resume(ExecutionController.java:63)

                • 5. Re: StatefulKnowledgeSessionImpl Serializable
                  Mauricio Salatino Master

                  The error that you mention could be generated by two or more threads trying to change the session at the same time, in that situation one of them one and all the others will fail. Cheers

                  1 of 1 people found this helpful