mpawlak
mpawlak

Reputation: 71

jBPM 6.0 ksession clustering

My application is based on jBPM 5 and because of some clustering problems I am testing jBPM 6 to replace the old version. I used example from: https://github.com/jsvitak/jbpm-6-examples/tree/master/rewards-basic

Unfortunately, as far as I have tested it, it still has issues with sharing the same KSession with multiple nodes.

The RuntimeManager was set to use singleton strategy.

  RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
            .newDefaultBuilder()
            .entityManagerFactory(emf)
            .addAsset(ResourceFactory.newClassPathResource("rewards-basic.bpmn"), ResourceType.BPMN2)
            .get();

        environment.getEnvironment().set(EnvironmentName.USE_PESSIMISTIC_LOCKING, true);
    singletonManager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
    RuntimeEngine runtime = singletonManager.getRuntimeEngine(new Context() {
        @Override
        public Object getContextId() {
            return singletonManager.getIdentifier();
        }
    });

 KieSession ksession = runtime.getKieSession();

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("recipient", recipient);
        ProcessInstance processInstance = ksession.startProcess(
                "com.sample.rewards-basic", params);

The test is simple:

  1. Create first process on node 1
  2. Create second process on node 2

And after step two, I always facing the same Hibernate exception as for jBPM 5:

Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.drools.persistence.info.SessionInfo#1]

On jBPM 5 I reloading the KSession from database, but I refering to it as workaround.

My application has the requirement that the same process instance must be accessible by different users logged to different nodes. Processes have human task, are stateful and are considered to be long-running (days, months). Tasks are carried out quickly.

So, my questions are:

  1. Can I use the same KSession on multiple nodes?
  2. If not, what are other mechanisms of jBPM 6 to synchronize processes' states between all nodes?
  3. If I use the different approach, will timers and events work in multiple nodes environment?

Upvotes: 4

Views: 1191

Answers (1)

mpawlak
mpawlak

Reputation: 71

Some answers to my questions above have been written in jbpm forum: https://community.jboss.org/message/863749#863749

Upvotes: 2

Related Questions