Search in sources :

Example 1 with BpmnProcessingException

use of io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException in project zeebe by camunda.

the class BpmnStateBehavior method canBeCompleted.

public boolean canBeCompleted(final BpmnElementContext context) {
    final ElementInstance flowScopeInstance = getFlowScopeInstance(context);
    if (flowScopeInstance == null) {
        return false;
    }
    final long activePaths = flowScopeInstance.getNumberOfActiveElementInstances() + flowScopeInstance.getActiveSequenceFlows();
    if (activePaths < 0) {
        throw new BpmnProcessingException(context, String.format("Expected number of active paths to be positive but got %d for instance %s", activePaths, flowScopeInstance));
    }
    return activePaths == 0;
}
Also used : BpmnProcessingException(io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException) ElementInstance(io.camunda.zeebe.engine.state.instance.ElementInstance)

Example 2 with BpmnProcessingException

use of io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException in project zeebe by camunda.

the class SubProcessProcessor method onActivate.

@Override
public void onActivate(final ExecutableFlowElementContainer element, final BpmnElementContext activating) {
    variableMappingBehavior.applyInputMappings(activating, element).flatMap(ok -> eventSubscriptionBehavior.subscribeToEvents(element, activating)).ifRightOrLeft(ok -> {
        final var activated = stateTransitionBehavior.transitionToActivated(activating);
        final ExecutableStartEvent startEvent = element.getNoneStartEvent();
        if (startEvent == null) {
            throw new BpmnProcessingException(activated, NO_NONE_START_EVENT_ERROR_MSG);
        }
        stateTransitionBehavior.activateChildInstance(activated, startEvent);
    }, failure -> incidentBehavior.createIncident(failure, activating));
}
Also used : BpmnElementContext(io.camunda.zeebe.engine.processing.bpmn.BpmnElementContext) BpmnStateTransitionBehavior(io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnStateTransitionBehavior) ExecutableStartEvent(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableStartEvent) BpmnIncidentBehavior(io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnIncidentBehavior) BpmnElementContainerProcessor(io.camunda.zeebe.engine.processing.bpmn.BpmnElementContainerProcessor) BpmnStateBehavior(io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnStateBehavior) ProcessInstanceIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent) BpmnEventSubscriptionBehavior(io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnEventSubscriptionBehavior) BpmnBehaviors(io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnBehaviors) BpmnProcessingException(io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException) BpmnVariableMappingBehavior(io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnVariableMappingBehavior) ExecutableFlowElementContainer(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElementContainer) ExecutableStartEvent(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableStartEvent) BpmnProcessingException(io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException)

Example 3 with BpmnProcessingException

use of io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException in project zeebe by camunda.

the class EventBasedGatewayProcessor method onComplete.

@Override
public void onComplete(final ExecutableEventBasedGateway element, final BpmnElementContext context) {
    eventSubscriptionBehavior.unsubscribeFromEvents(context);
    final var eventTrigger = eventSubscriptionBehavior.findEventTrigger(context).orElseThrow(() -> new BpmnProcessingException(context, "Expected an event trigger to complete the event-based gateway but not found."));
    // transition to completed and continue on the event of the gateway that was triggered
    // - according to the BPMN specification, the sequence flow to this event is not taken
    stateTransitionBehavior.transitionToCompleted(element, context).ifRightOrLeft(completed -> eventSubscriptionBehavior.activateTriggeredEvent(context.getElementInstanceKey(), completed.getFlowScopeKey(), eventTrigger, completed), failure -> incidentBehavior.createIncident(failure, context));
}
Also used : BpmnProcessingException(io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException)

Example 4 with BpmnProcessingException

use of io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException in project zeebe by zeebe-io.

the class EventBasedGatewayProcessor method onComplete.

@Override
public void onComplete(final ExecutableEventBasedGateway element, final BpmnElementContext context) {
    eventSubscriptionBehavior.unsubscribeFromEvents(context);
    final var eventTrigger = eventSubscriptionBehavior.findEventTrigger(context).orElseThrow(() -> new BpmnProcessingException(context, "Expected an event trigger to complete the event-based gateway but not found."));
    // transition to completed and continue on the event of the gateway that was triggered
    // - according to the BPMN specification, the sequence flow to this event is not taken
    stateTransitionBehavior.transitionToCompleted(element, context).ifRightOrLeft(completed -> eventSubscriptionBehavior.activateTriggeredEvent(context.getElementInstanceKey(), completed.getFlowScopeKey(), eventTrigger, completed), failure -> incidentBehavior.createIncident(failure, context));
}
Also used : BpmnProcessingException(io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException)

Example 5 with BpmnProcessingException

use of io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException in project zeebe by zeebe-io.

the class BpmnStateBehavior method canBeTerminated.

// used by canceling, since we don't care about active sequence flows
public boolean canBeTerminated(final BpmnElementContext context) {
    final ElementInstance flowScopeInstance = getFlowScopeInstance(context);
    if (flowScopeInstance == null) {
        return false;
    }
    final long activePaths = flowScopeInstance.getNumberOfActiveElementInstances();
    if (activePaths < 0) {
        throw new BpmnProcessingException(context, String.format("Expected number of active paths to be positive but got %d for instance %s", activePaths, flowScopeInstance));
    }
    return activePaths == 0;
}
Also used : BpmnProcessingException(io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException) ElementInstance(io.camunda.zeebe.engine.state.instance.ElementInstance)

Aggregations

BpmnProcessingException (io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException)15 ElementInstance (io.camunda.zeebe.engine.state.instance.ElementInstance)6 BpmnElementContainerProcessor (io.camunda.zeebe.engine.processing.bpmn.BpmnElementContainerProcessor)4 BpmnElementContext (io.camunda.zeebe.engine.processing.bpmn.BpmnElementContext)4 ProcessInstanceIntent (io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent)4 ProcessEngineMetrics (io.camunda.zeebe.engine.metrics.ProcessEngineMetrics)3 ProcessInstanceLifecycle (io.camunda.zeebe.engine.processing.bpmn.ProcessInstanceLifecycle)3 Failure (io.camunda.zeebe.engine.processing.common.Failure)3 ExecutableCallActivity (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableCallActivity)3 ExecutableFlowElement (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElement)3 ExecutableFlowNode (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowNode)3 ExecutableSequenceFlow (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableSequenceFlow)3 ExecutableStartEvent (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableStartEvent)3 StateWriter (io.camunda.zeebe.engine.processing.streamprocessor.writers.StateWriter)3 TypedCommandWriter (io.camunda.zeebe.engine.processing.streamprocessor.writers.TypedCommandWriter)3 Writers (io.camunda.zeebe.engine.processing.streamprocessor.writers.Writers)3 KeyGenerator (io.camunda.zeebe.engine.state.KeyGenerator)3 DeployedProcess (io.camunda.zeebe.engine.state.deployment.DeployedProcess)3 ElementInstanceState (io.camunda.zeebe.engine.state.immutable.ElementInstanceState)3 ProcessInstanceRecord (io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord)3