ParseListener

Hi. When I deploy new process definition version, parser is running like I expect for deployed process definition. But when I call API (TaskList, Cockpit) parser run again but not for all process definitions. It works randomly for some process definitions. How exactly parseListener works in these cases?

Hello @Elvin ,

the parse listener runs whenever a process definition is loaded to the engine.

As not all process definitions are in-memory all the time, sometimes a process definition is loaded from the database which would again trigger the parse listener to apply programmatic modifications to the model.

I hope this helps

Jonathan

Hello @jonathan.lukas . When a new process is deployed, I need to get its information and insert it into my own database, how can I do that? I only need this when the new version is deployed, how can I understand the difference if the parser is triggered while the process is being loaded to memory or just parsing for new deployment?

Hello @Elvin ,

for this purpose, there is the deployment listener. The interface is a bit different, yet it is possible to retrieve the binary data of a process definition.

The interface is org.camunda.bpm.engine.impl.persistence.deploy.Deployer and the plugin is configured to use getCustomPostDeployers().add(deployer) after eventually initialising the list of customPostDeployers.

I hope this helps

Jonathan

@jonathan.lukas , Sorry, I didn’t write the exact requirement. I need to get process definition, process version and user tasks when new version is deployed. I tried to do this with the following code (AbstractBpmnParseListener/parseUserTask) but the problem I mentioned appeared. I couldn’t quite figure out how to do it with the Deployer. Is there an example you can send?

public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {

ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) scope.getProcessDefinition();
ActivityBehavior activityBehavior = activity.getActivityBehavior();

if (activityBehavior instanceof UserTaskActivityBehavior) {
    ProcessDefinition dbDefinition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionKey(processDefinition.getKey())
            .latestVersion()
            .singleResult();
    UserTaskActivityBehavior userTask = (UserTaskActivityBehavior) activityBehavior;
    String userTaskName = userTaskElement.attribute("name");  }

Hello @Elvin ,

I have no example, yet the Deployer interface allows you to get deployed resources which also includes process definitions.

From there, you can use the content from the BPMN file directly or see the metadata that is appended to the deployment after it was done (this is why the deployer should be added as postDeployer).

Jonathan

@jonathan.lukas Thank you very much

1 Like