Find Message Start Events in Process Definition

Hi,

how do I get all the start event definitions from a process definition? In a form of ActivityImpl or whatever.

Looked all RepositoryService and RuntimeService methods and didn’t find anything appropriate by name…

/fedd

PS. This is an org.camunda.bpm.engine.repository.ProcessDefinition taken from the repositoryService PD query, which isn;t even a ProcessDefinitionImpl, that seems to have the methods I need…

Hello Fedd,

I am not sure if this is the best way of getting them but here you go:

    // get all message event subscriptions
    List<EventSubscription> list = runtimeService.createEventSubscriptionQuery().eventType("message").list(); 
    // you need to cast to EventSubscriptionEntity to get the activity
    EventSubscriptionEntity eventSubscription = (EventSubscriptionEntity) list.get(0);
    ActivityImpl activity = eventSubscription.getActivity();

Best regards,
Yana

You can analyse the modelInstance like this:

final Collection<MessageEventDefinition> messageEventDefinitions = modelInstance.getModelElementsByType(MessageEventDefinition.class);

How you get the modelinstance is the question, though. Maybe you could tell it a bit more about the use case?

@yana.vasileva thanks, will try. I need to specify the process definition. My Netbeans freezes and crashes all the time, but eventually I will find if this query builder allows this.

@jangalinski I am marrying Camunda with Apache Camel. Sorry how it sounds. When you deploy another process with start message events, the previous version should be found and deactivated. Probably I will have to cache the start subscription ids so no problem

Are you aware of GitHub - camunda-community-hub/camunda-platform-7-camel: Community Extension to add Apache Camel support for Camunda Platform 7?

3 Likes

no, I’m doing it differently.