cancel
Showing results for 
Search instead for 
Did you mean: 

General, easy question

djcameronsc
Champ in-the-making
Champ in-the-making
Hello

I've just started with Activiti - I notice in the Manning book, all the java code everywhere starts with the instantiation of a processEngine object like      ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration().buildProcessEngine();

But the API says  "Building a ProcessEngine is done through a ProcessEngineConfiguration instance and is a costly operation which should be avoided."

So is normally there a jvm running somewhere with that object instantiated all the time, that processes can attach to and use ?     An Activiti "server" so to speak ?     It doesn't seem like from the Manning book…..but maybe that comes later ….. ?
2 REPLIES 2

bmarkmann
Champ in-the-making
Champ in-the-making
The code in the book is mostly unit tests – creating the engine in those cases is appropriate, since you'd usually want a fresh (usually in-memory) database to work with.  At least for us, when you build an application that uses the process engine, it is created and configured once, when the application / application server starts up.  For instance, if you're using Spring, your bootstrapping of your Spring beans would create the process engine and you just use that one instance throughout your application (not re-creating it to handle every call).

frederikherema1
Star Contributor
Star Contributor
What bmakmann says, is right.

So is normally there a jvm running somewhere with that object instantiated all the time, that processes can attach to and use ? An Activiti "server" so to speak ? It doesn't seem like from the Manning book…..but maybe that comes later ….. ?

There is no JVM running at all times. The moment when you call the buildProcessEngine(), a process-engine is created an kept in memory in the current JVM, the method was called from. You can start using it's API.

As said before, for testing reasons, we sometimes recreate the process-engine. If it's in-memory, this is not such a costly operation and even then, for testing it doesn't really matter. If you're using the engine in an app, it generally is booted once (using webapp-context listener or spring/CDI) and shut down once.