RuntimeEngine runtime = manager.getRuntimeEngine(CorrelationKeyContext.get()); KieSession ksession = runtime.getKieSession(); RuntimeEngine runtime2 = manager.getRuntimeEngine(CorrelationKeyContext.get()); KieSession ksession2 = runtime2.getKieSession(); assertEquals(ProcessInstance.STATE_ACTIVE, pi2.getState()); runtime = manager.getRuntimeEngine(CorrelationKeyContext.get(key)); ksession = runtime.getKieSession(); assertEquals(ksession1Id, ksession.getIdentifier()); manager.getRuntimeEngine(CorrelationKeyContext.get(key)).getKieSession(); fail("Session for this (" + pi1.getId() + ") process instance is no more accessible"); } catch (RuntimeException e) { runtime2 = manager.getRuntimeEngine(CorrelationKeyContext.get(key2)); ksession2 = runtime2.getKieSession(); assertEquals(ksession2Id, ksession2.getIdentifier()); manager.getRuntimeEngine(CorrelationKeyContext.get(key2)).getKieSession(); fail("Session for this (" + pi2.getId() + ") process instance is no more accessible"); } catch (RuntimeException e) {
/** * Returns new instance of <code>CorrelationKeyContext</code> without correlation key. * Used for starting new instances of the process. * @return */ public static CorrelationKeyContext get() { return new CorrelationKeyContext(null); }
/** * Returns new instance of <code>CorrelationKeyContext</code> with correlation key of already existing process instance * @param key actual correlation key of process instance * @return */ public static CorrelationKeyContext get(CorrelationKey key) { return new CorrelationKeyContext(key); } }
/** * Gets a RuntimeEngine for a {@link Context} associated with the correlationKey. * @param correlationKey the correlationKey * @return the RuntimeEngine */ public RuntimeEngine getRuntimeEngine(CorrelationKey correlationKey) { return getRuntimeEngine(CorrelationKeyContext.get(correlationKey)); }
/** * Gets a RuntimeEngine for a {@link Context} associated with the correlationKey. * @param correlationKey the correlationKey * @return the RuntimeEngine */ public RuntimeEngine getRuntimeEngine(CorrelationKey correlationKey) { return getRuntimeEngine(CorrelationKeyContext.get(correlationKey)); }