Search in sources :

Example 1 with StartMessageDeployedEvents

use of org.activiti.api.runtime.event.impl.StartMessageDeployedEvents in project Activiti by Activiti.

the class StartMessageDeployedEventProducer method doStart.

public void doStart() {
    List<ProcessDefinition> processDefinitions = converter.from(repositoryService.createProcessDefinitionQuery().list());
    List<StartMessageDeployedEvent> messageDeployedEvents = new ArrayList<>();
    for (ProcessDefinition processDefinition : processDefinitions) {
        managementService.executeCommand(new FindStartMessageEventSubscriptions(processDefinition.getId())).stream().map(subscriptionConverter::convertToStartMessageSubscription).map(messageSubscription -> StartMessageDeploymentDefinitionImpl.builder().withMessageSubscription(messageSubscription).withProcessDefinition(processDefinition).build()).map(startMessageDeploymentDefinition -> StartMessageDeployedEventImpl.builder().withEntity(startMessageDeploymentDefinition).build()).forEach(messageDeployedEvents::add);
    }
    managementService.executeCommand(new DispatchStartMessageDeployedEvents(messageDeployedEvents));
    if (!messageDeployedEvents.isEmpty()) {
        eventPublisher.publishEvent(new StartMessageDeployedEvents(messageDeployedEvents));
    }
}
Also used : StartMessageDeploymentDefinitionImpl(org.activiti.api.runtime.model.impl.StartMessageDeploymentDefinitionImpl) MessageEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity) Logger(org.slf4j.Logger) StartMessageDeployedEvents(org.activiti.api.runtime.event.impl.StartMessageDeployedEvents) LoggerFactory(org.slf4j.LoggerFactory) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) CommandContext(org.activiti.engine.impl.interceptor.CommandContext) Collectors(java.util.stream.Collectors) ProcessRuntimeEventListener(org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener) ArrayList(java.util.ArrayList) RepositoryService(org.activiti.engine.RepositoryService) StartMessageDeployedEventImpl(org.activiti.api.runtime.event.impl.StartMessageDeployedEventImpl) List(java.util.List) ManagementService(org.activiti.engine.ManagementService) StartMessageSubscriptionConverter(org.activiti.runtime.api.event.impl.StartMessageSubscriptionConverter) EventSubscriptionQueryImpl(org.activiti.engine.impl.EventSubscriptionQueryImpl) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) StartMessageDeployedEvent(org.activiti.api.process.model.events.StartMessageDeployedEvent) APIProcessDefinitionConverter(org.activiti.runtime.api.model.impl.APIProcessDefinitionConverter) Command(org.activiti.engine.impl.interceptor.Command) ArrayList(java.util.ArrayList) StartMessageDeployedEvents(org.activiti.api.runtime.event.impl.StartMessageDeployedEvents) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) StartMessageDeployedEvent(org.activiti.api.process.model.events.StartMessageDeployedEvent)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ProcessDefinition (org.activiti.api.process.model.ProcessDefinition)1 StartMessageDeployedEvent (org.activiti.api.process.model.events.StartMessageDeployedEvent)1 ProcessRuntimeEventListener (org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener)1 StartMessageDeployedEventImpl (org.activiti.api.runtime.event.impl.StartMessageDeployedEventImpl)1 StartMessageDeployedEvents (org.activiti.api.runtime.event.impl.StartMessageDeployedEvents)1 StartMessageDeploymentDefinitionImpl (org.activiti.api.runtime.model.impl.StartMessageDeploymentDefinitionImpl)1 ManagementService (org.activiti.engine.ManagementService)1 RepositoryService (org.activiti.engine.RepositoryService)1 EventSubscriptionQueryImpl (org.activiti.engine.impl.EventSubscriptionQueryImpl)1 Command (org.activiti.engine.impl.interceptor.Command)1 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)1 MessageEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity)1 StartMessageSubscriptionConverter (org.activiti.runtime.api.event.impl.StartMessageSubscriptionConverter)1 APIProcessDefinitionConverter (org.activiti.runtime.api.model.impl.APIProcessDefinitionConverter)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)1