cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti Engine

tizo
Champ in-the-making
Champ in-the-making
Hi there,

In the company I work for, we are interested in using Activiti, but we don't really know where to start reading to design a proper solution for our environment. Particularly, we don't know what would be the best way to deploy the Activiti Engine.

We have some JEE projects running in GlassFish servers. The EJB ones contains stateless sessions beans, that are using content managed transactions (CMT) and JPA. We are thinking that we should continue using those EJBs, and should control the workflows from there.

Having that in mind, what do you think is the best solution for us?. Should we have the Activiti Engine in a totally independent server? Or could it be deployed in GlassFish?. Should we consider using an embedded engine in our EJBs? Or connecting to an external one?. Sorry about all those questions, but we have been searching in the documentation, and we could not find how exactly the engine can be deployed.

Thanks very much,

tizo
19 REPLIES 19

jbarrez
Star Contributor
Star Contributor
Both options are possible (ie independent or in a webapp).

It depends on your use case: do you want your processes to call EJB logic?
Or doy you want to manipulate workflows from those EJB's ?
(or a combination of both)

tizo
Champ in-the-making
Champ in-the-making
We want to manipulate the workflows from ours EJB's.

jbarrez
Star Contributor
Star Contributor
he easiest aproach is probably using Activiti as pojo in your EJB logic.
What could be interesting is, is storing the processEngine bean and/or services in jndi and have them autoinjected.

tizo
Champ in-the-making
Champ in-the-making
I was thinking in create an engine instance in a method annotated with @PostConstruct and destroy it (if it is necessary) in a method annotated with @PreDestroy. With this solution, there would be as many Activiti Engine instances, as there were EJBs instances. Would be a problem that all the engine instances access the same DB?.

jbarrez, how the engine could be stored in JNDI?

tizo
Champ in-the-making
Champ in-the-making
Ok, I have the engine working, having created an instance in a @PostConstruct method. I could make some tests with that, and the first thing that I have to say is that I like Activiti very much: it is easy to configure and make it work. As for that, I have some more questions/ideas.

1- The same old question: which would be the best way to use Activiti in our environment?. jbarrez give an interesting idea of storing the engine in jndi and have them autoinjected. How could that be done?.

2- Transactions: the user guide says "Currently only supports configuration by passing the jdbc properties (datasource through JNDI will be supported soon).". So I guess that Activiti manages its owns transactions. In my case, we are using JTA; CMT more precisely. That means that I can inject a datasource (having a JNDI name), and it act as any other transactional resource (for example, an Entity Manager using JPA), letting the container to manage the transactions. It would be good that I could pass this datasource to the engine to use it. Note that I think (maybe am I wrong?) that if the engine obtain a datasource through JNDI, it should manage the transactions too, so is not the same case.

3- DB schema: is there a way to choose on which DB schema Activiti tables should be created?.

Thanks very much,

tizo

jbarrez
Star Contributor
Star Contributor
I actually wouldnt use an engine/EJB: every engine has its own cache so your loosing some memory there by adding them to every EJB.

Regarding your questions:

1) I dont know for Glassfish, but in JBoss you have an annotation (or configuration, dont know exactly) that makes your logic execute on booting the server. That way you can create an bind your process engine to jndi.

2) That's not supported with the plain engine (altough 'naked' JTA / jndi datasource are high on our TODO list). However, you can use Spring for the moment and use the JTaTransactionManager and JNDI datasource wrappers there

3) When providing the database 'type' when you create the process engine, it automatically selects the right DDL script. Or do you mean that you want to delete some tables?

tizo
Champ in-the-making
Champ in-the-making
1- Ok. I will try it in GlassFish.  I am posting any advance.

2- Ok. It is not an option here to use Spring. As I said before, I think that if the engine obtain a datasource through JNDI, it should manage the transactions too (maybe I am wrong here?). On the contrary, we would like that our transactions (CMT ones) to be used by the engine. Anyway, for now we will try to call the engine methods exactly before finishing our EJBs method, and rollback our transactions in case an exception is caught here.

3- What I tried to mean here is if I can choose the DB schema to be used by Activiti tables. We are using PostgreSQL, and the tables are created right, but in the "public" schema. We have our DB organized in different schemas, so we would like the Activit tables to be in "activiti" schema. Of course I could change de DDL script, but I should change something more for the engine to know where the tables are.

Thanks very much,

tizo

jbarrez
Star Contributor
Star Contributor
2) That might work, but is not yet tested in our QA environment (and also not documented)

3) Yes, you can just add the tables to any schema (at least when I tried it manually here using pgadmin)

tizo
Champ in-the-making
Champ in-the-making
Just in case that someone is interested in this topic, answers for 1 and 2 can be found in the following thread (for Activiti 5.1): http://forums.activiti.org/en/viewtopic.php?f=6&t=922