Is it possible to deploy Flowable as a module and share it with multiple WebApps, having all of them accessing the same database (seeing the same processes and tasks)?
Yes, the engine operations are thread-safe and can be accessed by multiple apps in the same JVM.
If flowable-engine is deployed as a Wildfly module the method ProcessEngines.init(…) is called only once (the first time a WebApp is deployed).
When the second WebApp is deployed the ProcessEngines was already initialized, and the flowable.cfg.xml of the second WebApp is not read.
How do I fix it?
If you want to have a Flowable Engine that is shared with multiple web apps, using the same database, then it should not be needed to instantiate a new Flowable Engine for each web app right? It can be shared across the web apps?
Yes, that’s what I did.
Even so I still had to deal with a problem: when one of the WebApps was undeployed the LocalProcessEngineLookup was closing the ProcessEngine initialized before. Since the ProcessEngines.init(…) was not called again, I got in a situation in which no ProcessEngine was available.
The workaround was implement a custom ProcessEngineLookup that never closes the initialized ProcessEngine. This way all WebApps that share the same Flowable infrastructure must have the same flowable.cfg.xml, and the first one to be deployed will initialize the ProcessEngine to be shared by all of them. After that, each WebApp may deploy their own process definitions.