Search in sources :

Example 1 with EventSubscriptionManager

use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionManager in project camunda-bpm-platform by camunda.

the class MessageEventReceivedCmd method execute.

@Override
public Void execute(CommandContext commandContext) {
    ensureNotNull("executionId", executionId);
    EventSubscriptionManager eventSubscriptionManager = commandContext.getEventSubscriptionManager();
    List<EventSubscriptionEntity> eventSubscriptions = null;
    if (messageName != null) {
        eventSubscriptions = eventSubscriptionManager.findEventSubscriptionsByNameAndExecution(EventType.MESSAGE.name(), messageName, executionId, exclusive);
    } else {
        eventSubscriptions = eventSubscriptionManager.findEventSubscriptionsByExecutionAndType(executionId, EventType.MESSAGE.name(), exclusive);
    }
    ensureNotEmpty("Execution with id '" + executionId + "' does not have a subscription to a message event with name '" + messageName + "'", "eventSubscriptions", eventSubscriptions);
    ensureNumberOfElements("More than one matching message subscription found for execution " + executionId, "eventSubscriptions", eventSubscriptions, 1);
    // there can be only one:
    EventSubscriptionEntity eventSubscriptionEntity = eventSubscriptions.get(0);
    // check authorization
    String processInstanceId = eventSubscriptionEntity.getProcessInstanceId();
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkUpdateProcessInstanceById(processInstanceId);
    }
    eventSubscriptionEntity.eventReceived(processVariables, false);
    return null;
}
Also used : EventSubscriptionManager(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionManager) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 2 with EventSubscriptionManager

use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionManager in project camunda-bpm-platform by camunda.

the class BpmnDeployer method removeObsoleteEventSubscriptions.

protected void removeObsoleteEventSubscriptions(ProcessDefinitionEntity processDefinition, ProcessDefinitionEntity latestProcessDefinition) {
    // remove all subscriptions for the previous version
    if (latestProcessDefinition != null) {
        EventSubscriptionManager eventSubscriptionManager = getEventSubscriptionManager();
        List<EventSubscriptionEntity> subscriptionsToDelete = new ArrayList<EventSubscriptionEntity>();
        List<EventSubscriptionEntity> messageEventSubscriptions = eventSubscriptionManager.findEventSubscriptionsByConfiguration(EventType.MESSAGE.name(), latestProcessDefinition.getId());
        subscriptionsToDelete.addAll(messageEventSubscriptions);
        List<EventSubscriptionEntity> signalEventSubscriptions = eventSubscriptionManager.findEventSubscriptionsByConfiguration(EventType.SIGNAL.name(), latestProcessDefinition.getId());
        subscriptionsToDelete.addAll(signalEventSubscriptions);
        List<EventSubscriptionEntity> conditionalEventSubscriptions = eventSubscriptionManager.findEventSubscriptionsByConfiguration(EventType.CONDITONAL.name(), latestProcessDefinition.getId());
        subscriptionsToDelete.addAll(conditionalEventSubscriptions);
        for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsToDelete) {
            eventSubscriptionEntity.delete();
        }
    }
}
Also used : EventSubscriptionManager(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionManager) ArrayList(java.util.ArrayList) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 3 with EventSubscriptionManager

use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionManager in project camunda-bpm-platform by camunda.

the class SignalEventReceivedCmd method sendSignalToExecution.

protected void sendSignalToExecution(CommandContext commandContext, String signalName, String executionId) {
    ExecutionManager executionManager = commandContext.getExecutionManager();
    ExecutionEntity execution = executionManager.findExecutionById(executionId);
    ensureNotNull("Cannot find execution with id '" + executionId + "'", "execution", execution);
    EventSubscriptionManager eventSubscriptionManager = commandContext.getEventSubscriptionManager();
    List<EventSubscriptionEntity> signalEvents = eventSubscriptionManager.findSignalEventSubscriptionsByNameAndExecution(signalName, executionId);
    ensureNotEmpty("Execution '" + executionId + "' has not subscribed to a signal event with name '" + signalName + "'.", signalEvents);
    checkAuthorizationOfCatchSignals(commandContext, signalEvents);
    notifyExecutions(signalEvents);
}
Also used : EventSubscriptionManager(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionManager) ExecutionManager(org.camunda.bpm.engine.impl.persistence.entity.ExecutionManager) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Aggregations

EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)3 EventSubscriptionManager (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionManager)3 ArrayList (java.util.ArrayList)1 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)1 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)1 ExecutionManager (org.camunda.bpm.engine.impl.persistence.entity.ExecutionManager)1