Java Code Examples for org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity#getConfiguration()
The following examples show how to use
org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity#getConfiguration() .
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: CompensationInstanceHandler.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public void handle(MigratingInstanceParseContext parseContext, EventSubscriptionEntity element) { MigratingProcessElementInstance migratingInstance; if (element.getConfiguration() != null) { migratingInstance = createMigratingEventScopeInstance(parseContext, element); } else { migratingInstance = createMigratingEventSubscriptionInstance(parseContext, element); } ExecutionEntity owningExecution = element.getExecution(); MigratingScopeInstance parentInstance = null; if (owningExecution.isEventScope()) { parentInstance = parseContext.getMigratingCompensationInstanceByExecutionId(owningExecution.getId()); } else { parentInstance = parseContext.getMigratingActivityInstanceById(owningExecution.getParentActivityInstanceId()); } migratingInstance.setParent(parentInstance); }
Example 2
Source File: DefaultCorrelationHandler.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected List<CorrelationHandlerResult> correlateStartMessageByEventSubscription(CommandContext commandContext, String messageName, CorrelationSet correlationSet) { List<CorrelationHandlerResult> results = new ArrayList<CorrelationHandlerResult>(); DeploymentCache deploymentCache = commandContext.getProcessEngineConfiguration().getDeploymentCache(); List<EventSubscriptionEntity> messageEventSubscriptions = findMessageStartEventSubscriptions(commandContext, messageName, correlationSet); for (EventSubscriptionEntity messageEventSubscription : messageEventSubscriptions) { if (messageEventSubscription.getConfiguration() != null) { String processDefinitionId = messageEventSubscription.getConfiguration(); ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId); // only an active process definition will be returned if (processDefinition != null && !processDefinition.isSuspended()) { CorrelationHandlerResult result = CorrelationHandlerResult.matchedProcessDefinition(processDefinition, messageEventSubscription.getActivityId()); results.add(result); } else { LOG.couldNotFindProcessDefinitionForEventSubscription(messageEventSubscription, processDefinitionId); } } } return results; }
Example 3
Source File: SignalEventHandler.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void handleStartEvent(EventSubscriptionEntity eventSubscription, Map<String, Object> payload, String businessKey, CommandContext commandContext) { String processDefinitionId = eventSubscription.getConfiguration(); ensureNotNull("Configuration of signal start event subscription '" + eventSubscription.getId() + "' contains no process definition id.", processDefinitionId); DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache(); ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId); if (processDefinition == null || processDefinition.isSuspended()) { // ignore event subscription LOG.debugIgnoringEventSubscription(eventSubscription, processDefinitionId); } else { ActivityImpl signalStartEvent = processDefinition.findActivity(eventSubscription.getActivityId()); PvmProcessInstance processInstance = processDefinition.createProcessInstance(businessKey, signalStartEvent); processInstance.start(payload); } }
Example 4
Source File: SignalEventReceivedCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected Map<String, ProcessDefinitionEntity> getProcessDefinitionsOfSubscriptions(List<EventSubscriptionEntity> startSignalEventSubscriptions) { DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache(); Map<String, ProcessDefinitionEntity> processDefinitions = new HashMap<String, ProcessDefinitionEntity>(); for (EventSubscriptionEntity eventSubscription : startSignalEventSubscriptions) { String processDefinitionId = eventSubscription.getConfiguration(); ensureNotNull("Configuration of signal start event subscription '" + eventSubscription.getId() + "' contains no process definition id.", processDefinitionId); ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId); if (processDefinition != null && !processDefinition.isSuspended()) { processDefinitions.put(eventSubscription.getId(), processDefinition); } } return processDefinitions; }
Example 5
Source File: CompensationUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static ExecutionEntity getCompensatingExecution(EventSubscriptionEntity eventSubscription) { String configuration = eventSubscription.getConfiguration(); if (configuration != null) { return Context.getCommandContext().getExecutionManager().findExecutionById(configuration); } else { return null; } }
Example 6
Source File: CompensationEventHandler.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, Object localPayload, String businessKey, CommandContext commandContext) { eventSubscription.delete(); String configuration = eventSubscription.getConfiguration(); ensureNotNull("Compensating execution not set for compensate event subscription with id " + eventSubscription.getId(), "configuration", configuration); ExecutionEntity compensatingExecution = commandContext.getExecutionManager().findExecutionById(configuration); ActivityImpl compensationHandler = eventSubscription.getActivity(); // activate execution compensatingExecution.setActive(true); if (compensatingExecution.getActivity().getActivityBehavior() instanceof CompositeActivityBehavior) { compensatingExecution.getParent().setActivityInstanceId(compensatingExecution.getActivityInstanceId()); } if (compensationHandler.isScope() && !compensationHandler.isCompensationHandler()) { // descend into scope: List<EventSubscriptionEntity> eventsForThisScope = compensatingExecution.getCompensateEventSubscriptions(); CompensationUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false); } else { try { if (compensationHandler.isSubProcessScope() && compensationHandler.isTriggeredByEvent()) { compensatingExecution.executeActivity(compensationHandler); } else { // since we already have a scope execution, we don't need to create another one // for a simple scoped compensation handler compensatingExecution.setActivity(compensationHandler); compensatingExecution.performOperation(PvmAtomicOperation.ACTIVITY_START); } } catch (Exception e) { throw new ProcessEngineException("Error while handling compensation event " + eventSubscription, e); } } }
Example 7
Source File: TransactionSubProcessTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/bpmn/subprocess/transaction/TransactionSubProcessTest.testSimpleCase.bpmn20.xml"}) public void testSimpleCaseTxSuccessful() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("transactionProcess"); // after the process is started, we have compensate event subscriptions: assertEquals(5, runtimeService.createEventSubscriptionQuery().eventType("compensate").activityId("undoBookHotel").count()); assertEquals(1, runtimeService.createEventSubscriptionQuery().eventType("compensate").activityId("undoBookFlight").count()); // the task is present: Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); // making the tx succeed: taskService.setVariable(task.getId(), "confirmed", true); taskService.complete(task.getId()); // now the process instance execution is sitting in the 'afterSuccess' task // -> has left the transaction using the "normal" sequence flow List<String> activeActivityIds = runtimeService.getActiveActivityIds(processInstance.getId()); assertTrue(activeActivityIds.contains("afterSuccess")); // there is a compensate event subscription for the transaction under the process instance EventSubscriptionEntity eventSubscriptionEntity = (EventSubscriptionEntity) runtimeService.createEventSubscriptionQuery() .eventType("compensate").activityId("tx").executionId(processInstance.getId()).singleResult(); // there is an event-scope execution associated with the event-subscription: assertNotNull(eventSubscriptionEntity.getConfiguration()); Execution eventScopeExecution = runtimeService.createExecutionQuery().executionId(eventSubscriptionEntity.getConfiguration()).singleResult(); assertNotNull(eventScopeExecution); // there is a compensate event subscription for the miBody of 'bookHotel' activity EventSubscriptionEntity miBodyEventSubscriptionEntity = (EventSubscriptionEntity) runtimeService.createEventSubscriptionQuery() .eventType("compensate").activityId("bookHotel" + BpmnParse.MULTI_INSTANCE_BODY_ID_SUFFIX).executionId(eventScopeExecution.getId()).singleResult(); assertNotNull(miBodyEventSubscriptionEntity); String miBodyEventScopeExecutionId = miBodyEventSubscriptionEntity.getConfiguration(); // we still have compensate event subscriptions for the compensation handlers, only now they are part of the event scope assertEquals(5, runtimeService.createEventSubscriptionQuery().eventType("compensate").activityId("undoBookHotel").executionId(miBodyEventScopeExecutionId).count()); assertEquals(1, runtimeService.createEventSubscriptionQuery().eventType("compensate").activityId("undoBookFlight").executionId(eventScopeExecution.getId()).count()); assertEquals(1, runtimeService.createEventSubscriptionQuery().eventType("compensate").activityId("undoChargeCard").executionId(eventScopeExecution.getId()).count()); // assert that the compensation handlers have not been invoked: assertNull(runtimeService.getVariable(processInstance.getId(), "undoBookHotel")); assertNull(runtimeService.getVariable(processInstance.getId(), "undoBookFlight")); assertNull(runtimeService.getVariable(processInstance.getId(), "undoChargeCard")); // end the process instance runtimeService.signal(processInstance.getId()); assertProcessEnded(processInstance.getId()); assertEquals(0, runtimeService.createExecutionQuery().count()); }