Java Code Examples for org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity#eventReceived()

The following examples show how to use org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity#eventReceived() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThrowSignalEventActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(ActivityExecution execution) throws Exception {

  String businessKey = signalDefinition.getEventPayload().getBusinessKey(execution);
  VariableMap variableMap = signalDefinition.getEventPayload().getInputVariables(execution);

  String eventName = signalDefinition.resolveExpressionOfEventName(execution);
  // trigger all event subscriptions for the signal (start and intermediate)
  List<EventSubscriptionEntity> signalEventSubscriptions =
      findSignalEventSubscriptions(eventName, execution.getTenantId());

  for (EventSubscriptionEntity signalEventSubscription : signalEventSubscriptions) {
    if (isActiveEventSubscription(signalEventSubscription)) {
      signalEventSubscription.eventReceived(variableMap, null, businessKey, signalDefinition.isAsync());
    }
  }
  leave(execution);
}
 
Example 2
Source File: ProcessEventJobHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(EventSubscriptionJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) {
  // lookup subscription:
  String eventSubscriptionId = configuration.getEventSubscriptionId();
  EventSubscriptionEntity eventSubscription = commandContext.getEventSubscriptionManager()
    .findEventSubscriptionById(eventSubscriptionId);

  // if event subscription is null, ignore
  if(eventSubscription != null) {
    eventSubscription.eventReceived(null, false);
  }

}
 
Example 3
Source File: MessageEventReceivedCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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, processVariablesLocal, null, false);

  return null;
}
 
Example 4
Source File: SignalEventReceivedCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private void notifyExecutions(List<EventSubscriptionEntity> catchSignalEventSubscription) {

    for (EventSubscriptionEntity signalEventSubscriptionEntity : catchSignalEventSubscription) {
      if (isActiveEventSubscription(signalEventSubscriptionEntity)) {
        signalEventSubscriptionEntity.eventReceived(builder.getVariables(), false);
      }
    }
  }
 
Example 5
Source File: SendSignalDelegate.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  businessProcess.setVariable("processName", "throwSignal-visited (was " + businessProcess.getVariable("processName")  + ")");

  String signalProcessInstanceId = (String) execution.getVariable("signalProcessInstanceId");
  String executionId = runtimeService.createExecutionQuery().processInstanceId(signalProcessInstanceId).signalEventSubscriptionName("alert").singleResult().getId();

  CommandContext commandContext = Context.getCommandContext();
  List<EventSubscriptionEntity> findSignalEventSubscriptionsByEventName = commandContext
          .getEventSubscriptionManager()
          .findSignalEventSubscriptionsByNameAndExecution("alert", executionId);

  for (EventSubscriptionEntity signalEventSubscriptionEntity : findSignalEventSubscriptionsByEventName) {
      signalEventSubscriptionEntity.eventReceived(null, true);
  }
}