cancel
Showing results for 
Search instead for 
Did you mean: 

Deployment Listener

jcharnet
Champ in-the-making
Champ in-the-making
Does Acitiviti have any support for a deployment listener ?
I want to be able to get notified when a deployment is taken place, so that I can retrieve some information from the ACT_RE_PROCDEF table.

In my Application, we needed to make some relationships with our tables and activiti's tables. Of course we did not modify activiti tables, but we did create new tables that has reference to the activiti tables. One of our relationship, is with ACT_RE_PROCDEF, so when my user deploys a new bpmn xml file (through my application), I want to be able to get some information, like the id of the ACT_RE_PROCDEF table that has just been created.

Is it possible to achieve something like this ?


Thanks a lot.

John
9 REPLIES 9

frederikherema1
Star Contributor
Star Contributor
You can't specifically listen to deployment but you can, however, use a BPMNParseListener (search the forum, I remember a post where I explain how to hoot it in) which will be called when a bmpn20.xml file is parsed. The parsing happens when a NEW process is deployed, but also when the a process-definition is loaded that was not in the cache (in normal circumstances, this is only once while the engine is running).

I guess you can leverage this concept, and possibly check if the version you're about to parse matches your own domain-model bean that matches the PROC_DEF_

jcharnet
Champ in-the-making
Champ in-the-making
Thanks for the reply.
I'm trying it out, but it seems that when my listener is being called the ProcessDefinition object, has a null id attribute.
Is this normal ?

Inspecting the ProcessElement object, I am able to get the ID, but this ID will not match the column ID_ in the ACT_RE_PROCDEF table, because in the table it has two numbers after the id name. One I beleive is the version, the other I'm not quite sure what it is !
Ex:
If I define in my workflow an id = "TestWorkflowConditionalLoop", in the ID_ column of ACT_RE_PROCDEF I would have something like this:
"TestWorkflowConditionalLoop:1:4431". Correct ?

This is what I need to map on my side.

Thanks

frederikherema1
Star Contributor
Star Contributor
The id value in the XML-element is actually the "key" in the process-definition bean. So use the "ProcessDefinitionEntity processDefinition" passed in the method instead, this is already populated with the values from the XML-element. The XML-element is only passed to do additional parsing, not done by default BPMN parsing on our side…

jcharnet
Champ in-the-making
Champ in-the-making
I tried using the ProcessDefinitionEntity, but the id atribute is null (processDefinition.getId()).

frederikherema1
Star Contributor
Star Contributor
I see… is this for a new process, or is the ID also null for existing processes? AFAIK, the ID is assigned after the entity has been created in case of a new process/deployment. Makes sense that the ID is null there, using the parseListener approach.

jcharnet
Champ in-the-making
Champ in-the-making
It is for a new process. I did not try it for an existing process. For my case, I would need to use it for new processes.
Another thing I tried, was to query ACT_RE_PROCDEF with createTablePageQuery().tableName("act_re_procdef"). It this is done in the ParseListener, my process is still not in the database.

Any other idea, for what I need to do ?

Thanks

jcharnet
Champ in-the-making
Champ in-the-making
I've managed to get this working without any listener (not using ParseListener).
After I have deployed the xml, I query the ACT_RE_PROCDEF finding the newly created DeploymentId, and I get the latest version of the xml.

This seems to be working for me.

Thanks for all the help !


Sincerely,

John

ytsejammer
Champ in-the-making
Champ in-the-making
Hi,

Have there been any new features added to the Activiti engine to enable listeners for new process definitions being deployed/undeployed?

Thanks,

Carlos

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Just create some code that does the deployement… In that code you can do whatever you want… much cleaner I think