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

    StatefulKnowledgeSessionImpl Serializable

    dondragon2

      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?

       

      Regards

      Donald

        • 1. Re: StatefulKnowledgeSessionImpl Serializable
          salaboy21

          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.

          Cheers

          • 2. Re: StatefulKnowledgeSessionImpl Serializable
            dondragon2

            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
              salaboy21

              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.

               

              Cheers

              • 4. Re: StatefulKnowledgeSessionImpl Serializable
                dondragon2

                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

                java.lang.NullPointerException

                          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
                  salaboy21

                  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