Book Image

Mastering jBPM6

By : Simone Fiorini, Arun V Gopalakrishnan
Book Image

Mastering jBPM6

By: Simone Fiorini, Arun V Gopalakrishnan

Overview of this book

Table of Contents (18 chapters)
Mastering jBPM6
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

KieSession


KieSession is a stateful session that maintains its conversational state with the engine, across multiple interactions. It is the best way to interact with the engine. Sessions are created starting from KieContainer, KieBase, or configured RuntimeEngine, which always delegates to KieBase but gives you the flexibility of choosing a session runtime policy.

Depending on the enabling of persistence, the session is created as follows:

  • In-memory session: All data related to session and the engine status is kept in memory and lost on engine restart

  • JTA session: Session persisted through a JPA EntityManager and a JTA transaction manager

To create a new (stateful) KieSession, we configure the environment and we use JPAKnowledgeService:

Environment env = KnowledgeBaseFactory.newEnvironment();
EntityManagerFactory emf= Persistence.createEntityManagerFactory( "com.packt.masterjbpm6.persistenceunit" ));
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,emf);
env.set( EnvironmentName.TRANSACTION_MANAGER...