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);
}
}
}
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);
});
}
}
}
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);
}
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);
});
}
}
}
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);
}
}
}
Aggregations