Search in sources :

Example 1 with ExecutableCatchEventElement

use of io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableCatchEventElement in project zeebe by camunda.

the class DeploymentCreateProcessor method subscribeToTimerStartEventIfExists.

private void subscribeToTimerStartEventIfExists(final TypedStreamWriter streamWriter, final SideEffects sideEffects, final ProcessMetadata processMetadata, final List<ExecutableStartEvent> startEvents) {
    for (final ExecutableCatchEventElement startEvent : startEvents) {
        if (startEvent.isTimer()) {
            // There are no variables when there is no process instance yet,
            // we use a negative scope key to indicate this
            final long scopeKey = -1L;
            final Either<Failure, Timer> timerOrError = startEvent.getTimerFactory().apply(expressionProcessor, scopeKey);
            if (timerOrError.isLeft()) {
                // todo(#4323): deal with this exceptional case without throwing an exception
                throw new EvaluationException(timerOrError.getLeft().getMessage());
            }
            catchEventBehavior.subscribeToTimerEvent(NO_ELEMENT_INSTANCE, NO_ELEMENT_INSTANCE, processMetadata.getKey(), startEvent.getId(), timerOrError.get(), streamWriter, sideEffects);
        }
    }
}
Also used : Timer(io.camunda.zeebe.model.bpmn.util.time.Timer) ExecutableCatchEventElement(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableCatchEventElement) EvaluationException(io.camunda.zeebe.engine.processing.common.ExpressionProcessor.EvaluationException) Failure(io.camunda.zeebe.engine.processing.common.Failure)

Example 2 with ExecutableCatchEventElement

use of io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableCatchEventElement in project zeebe by camunda.

the class MessageStartEventSubscriptionManager method openMessageStartEventSubscriptions.

private void openMessageStartEventSubscriptions(final ProcessMetadata processRecord, final StateWriter stateWriter) {
    final long processDefinitionKey = processRecord.getKey();
    final DeployedProcess processDefinition = processState.getProcessByKey(processDefinitionKey);
    final ExecutableProcess process = processDefinition.getProcess();
    final List<ExecutableStartEvent> startEvents = process.getStartEvents();
    // if startEvents contain message events
    for (final ExecutableCatchEventElement startEvent : startEvents) {
        if (startEvent.isMessage()) {
            final ExecutableMessage message = startEvent.getMessage();
            message.getMessageName().map(BufferUtil::wrapString).ifPresent(messageNameBuffer -> {
                subscriptionRecord.reset();
                subscriptionRecord.setMessageName(messageNameBuffer).setProcessDefinitionKey(processDefinitionKey).setBpmnProcessId(process.getId()).setStartEventId(startEvent.getId());
                final var subscriptionKey = keyGenerator.nextKey();
                stateWriter.appendFollowUpEvent(subscriptionKey, MessageStartEventSubscriptionIntent.CREATED, subscriptionRecord);
            });
        }
    }
}
Also used : ExecutableMessage(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableMessage) DeployedProcess(io.camunda.zeebe.engine.state.deployment.DeployedProcess) ExecutableStartEvent(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableStartEvent) ExecutableCatchEventElement(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableCatchEventElement) ExecutableProcess(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableProcess)

Example 3 with ExecutableCatchEventElement

use of io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableCatchEventElement in project zeebe by camunda.

the class IntermediateCatchEventTransformer method transform.

@Override
public void transform(final IntermediateCatchEvent element, final TransformContext context) {
    final ExecutableProcess process = context.getCurrentProcess();
    final ExecutableCatchEventElement executableElement = process.getElementById(element.getId(), ExecutableCatchEventElement.class);
    final var isConnectedToEventBasedGateway = executableElement.getIncoming().stream().map(ExecutableSequenceFlow::getSource).anyMatch(source -> source.getElementType() == BpmnElementType.EVENT_BASED_GATEWAY);
    executableElement.setConnectedToEventBasedGateway(isConnectedToEventBasedGateway);
}
Also used : ExecutableCatchEventElement(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableCatchEventElement) ExecutableProcess(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableProcess)

Example 4 with ExecutableCatchEventElement

use of io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableCatchEventElement in project zeebe by zeebe-io.

the class MessageStartEventSubscriptionManager method openMessageStartEventSubscriptions.

private void openMessageStartEventSubscriptions(final ProcessMetadata processRecord, final StateWriter stateWriter) {
    final long processDefinitionKey = processRecord.getKey();
    final DeployedProcess processDefinition = processState.getProcessByKey(processDefinitionKey);
    final ExecutableProcess process = processDefinition.getProcess();
    final List<ExecutableStartEvent> startEvents = process.getStartEvents();
    // if startEvents contain message events
    for (final ExecutableCatchEventElement startEvent : startEvents) {
        if (startEvent.isMessage()) {
            final ExecutableMessage message = startEvent.getMessage();
            message.getMessageName().map(BufferUtil::wrapString).ifPresent(messageNameBuffer -> {
                subscriptionRecord.reset();
                subscriptionRecord.setMessageName(messageNameBuffer).setProcessDefinitionKey(processDefinitionKey).setBpmnProcessId(process.getId()).setStartEventId(startEvent.getId());
                final var subscriptionKey = keyGenerator.nextKey();
                stateWriter.appendFollowUpEvent(subscriptionKey, MessageStartEventSubscriptionIntent.CREATED, subscriptionRecord);
            });
        }
    }
}
Also used : ExecutableMessage(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableMessage) DeployedProcess(io.camunda.zeebe.engine.state.deployment.DeployedProcess) ExecutableStartEvent(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableStartEvent) ExecutableCatchEventElement(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableCatchEventElement) ExecutableProcess(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableProcess)

Example 5 with ExecutableCatchEventElement

use of io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableCatchEventElement in project zeebe by camunda-cloud.

the class DeploymentCreateProcessor method subscribeToTimerStartEventIfExists.

private void subscribeToTimerStartEventIfExists(final TypedStreamWriter streamWriter, final SideEffects sideEffects, final ProcessMetadata processMetadata, final List<ExecutableStartEvent> startEvents) {
    for (final ExecutableCatchEventElement startEvent : startEvents) {
        if (startEvent.isTimer()) {
            // There are no variables when there is no process instance yet,
            // we use a negative scope key to indicate this
            final long scopeKey = -1L;
            final Either<Failure, Timer> timerOrError = startEvent.getTimerFactory().apply(expressionProcessor, scopeKey);
            if (timerOrError.isLeft()) {
                // todo(#4323): deal with this exceptional case without throwing an exception
                throw new EvaluationException(timerOrError.getLeft().getMessage());
            }
            catchEventBehavior.subscribeToTimerEvent(NO_ELEMENT_INSTANCE, NO_ELEMENT_INSTANCE, processMetadata.getKey(), startEvent.getId(), timerOrError.get(), streamWriter, sideEffects);
        }
    }
}
Also used : Timer(io.camunda.zeebe.model.bpmn.util.time.Timer) ExecutableCatchEventElement(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableCatchEventElement) EvaluationException(io.camunda.zeebe.engine.processing.common.ExpressionProcessor.EvaluationException) Failure(io.camunda.zeebe.engine.processing.common.Failure)

Aggregations

ExecutableCatchEventElement (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableCatchEventElement)15 ExecutableProcess (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableProcess)12 Failure (io.camunda.zeebe.engine.processing.common.Failure)6 ExecutableMessage (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableMessage)6 Expression (io.camunda.zeebe.el.Expression)3 ExpressionLanguage (io.camunda.zeebe.el.ExpressionLanguage)3 EvaluationException (io.camunda.zeebe.engine.processing.common.ExpressionProcessor.EvaluationException)3 ExecutableStartEvent (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableStartEvent)3 ModelElementTransformer (io.camunda.zeebe.engine.processing.deployment.model.transformation.ModelElementTransformer)3 TransformContext (io.camunda.zeebe.engine.processing.deployment.model.transformation.TransformContext)3 DeployedProcess (io.camunda.zeebe.engine.state.deployment.DeployedProcess)3 CatchEvent (io.camunda.zeebe.model.bpmn.instance.CatchEvent)3 ErrorEventDefinition (io.camunda.zeebe.model.bpmn.instance.ErrorEventDefinition)3 EventDefinition (io.camunda.zeebe.model.bpmn.instance.EventDefinition)3 Message (io.camunda.zeebe.model.bpmn.instance.Message)3 MessageEventDefinition (io.camunda.zeebe.model.bpmn.instance.MessageEventDefinition)3 TimerEventDefinition (io.camunda.zeebe.model.bpmn.instance.TimerEventDefinition)3 RepeatingInterval (io.camunda.zeebe.model.bpmn.util.time.RepeatingInterval)3 TimeDateTimer (io.camunda.zeebe.model.bpmn.util.time.TimeDateTimer)3 Timer (io.camunda.zeebe.model.bpmn.util.time.Timer)3