cancel
Showing results for 
Search instead for 
Did you mean: 

Why message/signal event subscriptions removed when deploying new version of process definition?

fersmi
Champ in-the-making
Champ in-the-making

Why message/signal event subscriptions removed when deploying new version of process definition? Why they don't stay on the previous version? Process instances still stay on the previous version, or not?

It makes no sense. I want to keep them on the previous version.

I use Activiti version 5.20.0.1.

6 REPLIES 6

jearles
Star Contributor
Star Contributor

Fersmi_,

In the Activiti User Guide, particularly in the areas surrounding event subscriptions, I found a couple of relevant mentions. Particularly that when that, upon the "deployment of a new version of a process definition, the message subscriptions of the previous version are cancelled".

Other helpful bits in this case:

  • "In the case of a message start event, the message event subscription is associated with a particular process definition"
    • "Since there can only be one process definition for a specific message subscription, the query always returns zero or one results. If a process definition is updated, only the newest version of the process definition has a subscription to the message event."
  • "In the case of an intermediate catch message event, the message event subscription is associated with a particular execution"

It sounds like from the user guide, that what you're experiencing is intended default behavior.

-JEarles
bp3

fersmi
Champ in-the-making
Champ in-the-making

Hi Jonathan,

thank you for your answer.

I have another question. Do you know what happens, when event is triggered and process definition is different for event subscription (new version) and process instance (old version)? It will work?

Fersmi

fersmi
Champ in-the-making
Champ in-the-making

It's definitely wrong. I have upgraded to latest version 5.22.0 and there BpmnDeployer remove only event subscription with no execution id and process instance id. Not all event subscriptions.

That makes sense!

gdharley
Elite Collaborator
Elite Collaborator

Jakob, 
I can assure you that event, message and timer subscriptions for existing process definition version are removed and updated when a new version of a process definition is deployed.

a snippet from the deploy code:

  removeObsoleteTimers(processDefinition);
addTimerDeclarations(processDefinition, timers);

removeExistingMessageEventSubscriptions(processDefinition, latestProcessDefinition);
addMessageEventSubscriptions(processDefinition);

removeExistingSignalEventSubScription(processDefinition, latestProcessDefinition);
addSignalEventSubscriptions(processDefinition);

Feel free to take a look at the code yourself, but to summarize.
Event and message subscriptions are queried against the "latest" deployment (i.e. the one currently deployed) and associated tenant ID. The resulting list is iterated over and the subscription is deleted.

After each step, the new subscriptions for the process definition being deployed are added.

Not sure what you mean by "not all event subscriptions", perhaps you can provide a specific example (preferably as a unit test).

Thanks,
Greg

fersmi
Champ in-the-making
Champ in-the-making

Hi Greg,

I have upgraded Activiti to version 5.22.0 and the query to select event subscriptions (used during deployment of new version) is now make sense. Only event subscriptions WITHOUT execution ID and process instance ID:

    select *
    from ${prefix}ACT_RU_EVENT_SUBSCR
    <where>
        <if test="parameter.eventType != null">
          (EVENT_TYPE_ = #{parameter.eventType})
        </if>
          and PROC_DEF_ID_ = #{parameter.processDefinitionId}
          and EXECUTION_ID_ is null
          and PROC_INST_ID_ is null
         <if test="parameter.tenantId != null">
            and TENANT_ID_ = #{parameter.tenantId}
        </if>  
        <if test="parameter.tenantId == null">
            and (TENANT_ID_ = '' or TENANT_ID_ is null)
        </if>  
    </where>

but in version 5.20.0 was

select *
    from ${prefix}ACT_RU_EVENT_SUBSCR
    where (EVENT_TYPE_ = #{parameter.eventType})
        and (
           (CONFIGURATION_ = #{parameter.configuration})
           or
           (PROC_DEF_ID_ = #{parameter.configuration})
        )
     <if test="parameter.tenantId != null">
        and TENANT_ID_ = #{parameter.tenantId}
    </if>  
    <if test="parameter.tenantId == null">
        and (TENANT_ID_ = '' or TENANT_ID_ is null)
    </if>

which select all event subscriptions for previous version of process definition. I think that was big bug.

Fersmi

gdharley
Elite Collaborator
Elite Collaborator

Agree, deleting all jobs, including those with an associated execution id was a defect.

Thanks,

Greg