Search in sources :

Example 1 with ExpressionProcessor

use of io.camunda.zeebe.engine.processing.common.ExpressionProcessor in project zeebe by zeebe-io.

the class EngineProcessors method createEngineProcessors.

public static TypedRecordProcessors createEngineProcessors(final ProcessingContext processingContext, final int partitionsCount, final SubscriptionCommandSender subscriptionCommandSender, final DeploymentDistributor deploymentDistributor, final DeploymentResponder deploymentResponder, final Consumer<String> onJobsAvailableCallback) {
    final var actor = processingContext.getActor();
    final MutableZeebeState zeebeState = processingContext.getZeebeState();
    final var writers = processingContext.getWriters();
    final TypedRecordProcessors typedRecordProcessors = TypedRecordProcessors.processors(zeebeState.getKeyGenerator(), writers);
    // register listener that handles migrations immediately, so it is the first to be called
    typedRecordProcessors.withListener(new DbMigrationController());
    typedRecordProcessors.withListener(processingContext.getZeebeState());
    final LogStream stream = processingContext.getLogStream();
    final int partitionId = stream.getPartitionId();
    final var variablesState = zeebeState.getVariableState();
    final var expressionProcessor = new ExpressionProcessor(ExpressionLanguageFactory.createExpressionLanguage(), variablesState::getVariable);
    final DueDateTimerChecker timerChecker = new DueDateTimerChecker(zeebeState.getTimerState());
    final CatchEventBehavior catchEventBehavior = new CatchEventBehavior(zeebeState, expressionProcessor, subscriptionCommandSender, writers.state(), timerChecker, partitionsCount);
    final var eventTriggerBehavior = new EventTriggerBehavior(zeebeState.getKeyGenerator(), catchEventBehavior, writers, zeebeState);
    final var eventPublicationBehavior = new BpmnEventPublicationBehavior(zeebeState, zeebeState.getKeyGenerator(), eventTriggerBehavior, writers);
    addDeploymentRelatedProcessorAndServices(catchEventBehavior, partitionId, zeebeState, typedRecordProcessors, deploymentResponder, expressionProcessor, writers, partitionsCount, actor, deploymentDistributor, zeebeState.getKeyGenerator());
    addMessageProcessors(eventTriggerBehavior, subscriptionCommandSender, zeebeState, typedRecordProcessors, writers);
    final var jobMetrics = new JobMetrics(partitionId);
    final TypedRecordProcessor<ProcessInstanceRecord> bpmnStreamProcessor = addProcessProcessors(zeebeState, expressionProcessor, typedRecordProcessors, subscriptionCommandSender, catchEventBehavior, eventTriggerBehavior, writers, timerChecker, jobMetrics);
    JobEventProcessors.addJobProcessors(typedRecordProcessors, zeebeState, onJobsAvailableCallback, eventPublicationBehavior, writers, jobMetrics, eventTriggerBehavior);
    addIncidentProcessors(zeebeState, bpmnStreamProcessor, typedRecordProcessors, writers, zeebeState.getKeyGenerator());
    return typedRecordProcessors;
}
Also used : MutableZeebeState(io.camunda.zeebe.engine.state.mutable.MutableZeebeState) BpmnEventPublicationBehavior(io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnEventPublicationBehavior) LogStream(io.camunda.zeebe.logstreams.log.LogStream) DueDateTimerChecker(io.camunda.zeebe.engine.processing.timer.DueDateTimerChecker) JobMetrics(io.camunda.zeebe.engine.metrics.JobMetrics) CatchEventBehavior(io.camunda.zeebe.engine.processing.common.CatchEventBehavior) TypedRecordProcessors(io.camunda.zeebe.engine.processing.streamprocessor.TypedRecordProcessors) ExpressionProcessor(io.camunda.zeebe.engine.processing.common.ExpressionProcessor) EventTriggerBehavior(io.camunda.zeebe.engine.processing.common.EventTriggerBehavior) ProcessInstanceRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord) DbMigrationController(io.camunda.zeebe.engine.state.migration.DbMigrationController)

Example 2 with ExpressionProcessor

use of io.camunda.zeebe.engine.processing.common.ExpressionProcessor in project zeebe by camunda-cloud.

the class EngineProcessors method createEngineProcessors.

public static TypedRecordProcessors createEngineProcessors(final ProcessingContext processingContext, final int partitionsCount, final SubscriptionCommandSender subscriptionCommandSender, final DeploymentDistributor deploymentDistributor, final DeploymentResponder deploymentResponder, final Consumer<String> onJobsAvailableCallback) {
    final var actor = processingContext.getActor();
    final MutableZeebeState zeebeState = processingContext.getZeebeState();
    final var writers = processingContext.getWriters();
    final TypedRecordProcessors typedRecordProcessors = TypedRecordProcessors.processors(zeebeState.getKeyGenerator(), writers);
    // register listener that handles migrations immediately, so it is the first to be called
    typedRecordProcessors.withListener(new DbMigrationController());
    typedRecordProcessors.withListener(processingContext.getZeebeState());
    final LogStream stream = processingContext.getLogStream();
    final int partitionId = stream.getPartitionId();
    final var variablesState = zeebeState.getVariableState();
    final var expressionProcessor = new ExpressionProcessor(ExpressionLanguageFactory.createExpressionLanguage(), variablesState::getVariable);
    final DueDateTimerChecker timerChecker = new DueDateTimerChecker(zeebeState.getTimerState());
    final CatchEventBehavior catchEventBehavior = new CatchEventBehavior(zeebeState, expressionProcessor, subscriptionCommandSender, writers.state(), timerChecker, partitionsCount);
    final var eventTriggerBehavior = new EventTriggerBehavior(zeebeState.getKeyGenerator(), catchEventBehavior, writers, zeebeState);
    final var eventPublicationBehavior = new BpmnEventPublicationBehavior(zeebeState, zeebeState.getKeyGenerator(), eventTriggerBehavior, writers);
    addDeploymentRelatedProcessorAndServices(catchEventBehavior, partitionId, zeebeState, typedRecordProcessors, deploymentResponder, expressionProcessor, writers, partitionsCount, actor, deploymentDistributor, zeebeState.getKeyGenerator());
    addMessageProcessors(eventTriggerBehavior, subscriptionCommandSender, zeebeState, typedRecordProcessors, writers);
    final var jobMetrics = new JobMetrics(partitionId);
    final TypedRecordProcessor<ProcessInstanceRecord> bpmnStreamProcessor = addProcessProcessors(zeebeState, expressionProcessor, typedRecordProcessors, subscriptionCommandSender, catchEventBehavior, eventTriggerBehavior, writers, timerChecker, jobMetrics);
    JobEventProcessors.addJobProcessors(typedRecordProcessors, zeebeState, onJobsAvailableCallback, eventPublicationBehavior, writers, jobMetrics, eventTriggerBehavior);
    addIncidentProcessors(zeebeState, bpmnStreamProcessor, typedRecordProcessors, writers, zeebeState.getKeyGenerator());
    return typedRecordProcessors;
}
Also used : MutableZeebeState(io.camunda.zeebe.engine.state.mutable.MutableZeebeState) BpmnEventPublicationBehavior(io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnEventPublicationBehavior) LogStream(io.camunda.zeebe.logstreams.log.LogStream) DueDateTimerChecker(io.camunda.zeebe.engine.processing.timer.DueDateTimerChecker) JobMetrics(io.camunda.zeebe.engine.metrics.JobMetrics) CatchEventBehavior(io.camunda.zeebe.engine.processing.common.CatchEventBehavior) TypedRecordProcessors(io.camunda.zeebe.engine.processing.streamprocessor.TypedRecordProcessors) ExpressionProcessor(io.camunda.zeebe.engine.processing.common.ExpressionProcessor) EventTriggerBehavior(io.camunda.zeebe.engine.processing.common.EventTriggerBehavior) ProcessInstanceRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord) DbMigrationController(io.camunda.zeebe.engine.state.migration.DbMigrationController)

Example 3 with ExpressionProcessor

use of io.camunda.zeebe.engine.processing.common.ExpressionProcessor in project zeebe by zeebe-io.

the class ProcessValidationUtil method validate.

private static ValidationResults validate(final BpmnModelInstance model) {
    final ModelWalker walker = new ModelWalker(model);
    final ExpressionLanguage expressionLanguage = ExpressionLanguageFactory.createExpressionLanguage();
    final EvaluationContextLookup emptyLookup = scopeKey -> name -> null;
    final var expressionProcessor = new ExpressionProcessor(expressionLanguage, emptyLookup);
    final ValidationVisitor visitor = new ValidationVisitor(Stream.of(ZeebeRuntimeValidators.getValidators(expressionLanguage, expressionProcessor), ZeebeDesignTimeValidators.VALIDATORS).flatMap(Collection::stream).collect(Collectors.toList()));
    walker.walk(visitor);
    return visitor.getValidationResult();
}
Also used : EvaluationContextLookup(io.camunda.zeebe.engine.processing.common.ExpressionProcessor.EvaluationContextLookup) ExpressionLanguageFactory(io.camunda.zeebe.el.ExpressionLanguageFactory) ValidationVisitor(io.camunda.zeebe.model.bpmn.validation.ValidationVisitor) ZeebeDesignTimeValidators(io.camunda.zeebe.model.bpmn.validation.zeebe.ZeebeDesignTimeValidators) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EvaluationContextLookup(io.camunda.zeebe.engine.processing.common.ExpressionProcessor.EvaluationContextLookup) Collection(java.util.Collection) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) Collectors(java.util.stream.Collectors) ExpressionProcessor(io.camunda.zeebe.engine.processing.common.ExpressionProcessor) Stream(java.util.stream.Stream) ModelWalker(io.camunda.zeebe.model.bpmn.traversal.ModelWalker) ExpressionLanguage(io.camunda.zeebe.el.ExpressionLanguage) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) ValidationResults(org.camunda.bpm.model.xml.validation.ValidationResults) ValidationVisitor(io.camunda.zeebe.model.bpmn.validation.ValidationVisitor) ExpressionProcessor(io.camunda.zeebe.engine.processing.common.ExpressionProcessor) Collection(java.util.Collection) ModelWalker(io.camunda.zeebe.model.bpmn.traversal.ModelWalker) ExpressionLanguage(io.camunda.zeebe.el.ExpressionLanguage)

Example 4 with ExpressionProcessor

use of io.camunda.zeebe.engine.processing.common.ExpressionProcessor in project zeebe by zeebe-io.

the class EngineProcessors method createEngineProcessors.

public static TypedRecordProcessors createEngineProcessors(final ProcessingContext processingContext, final int partitionsCount, final SubscriptionCommandSender subscriptionCommandSender, final DeploymentDistributor deploymentDistributor, final DeploymentResponder deploymentResponder, final Consumer<String> onJobsAvailableCallback, final FeatureFlags featureFlags) {
    final var actor = processingContext.getActor();
    final MutableZeebeState zeebeState = processingContext.getZeebeState();
    final var writers = processingContext.getWriters();
    final TypedRecordProcessors typedRecordProcessors = TypedRecordProcessors.processors(zeebeState.getKeyGenerator(), writers);
    // register listener that handles migrations immediately, so it is the first to be called
    typedRecordProcessors.withListener(new DbMigrationController());
    typedRecordProcessors.withListener(processingContext.getZeebeState());
    final LogStream stream = processingContext.getLogStream();
    final int partitionId = stream.getPartitionId();
    final var variablesState = zeebeState.getVariableState();
    final var expressionProcessor = new ExpressionProcessor(ExpressionLanguageFactory.createExpressionLanguage(), new VariableStateEvaluationContextLookup(variablesState));
    final DueDateTimerChecker timerChecker = new DueDateTimerChecker(zeebeState.getTimerState(), featureFlags);
    final CatchEventBehavior catchEventBehavior = new CatchEventBehavior(zeebeState, zeebeState.getKeyGenerator(), expressionProcessor, subscriptionCommandSender, writers.state(), timerChecker, partitionsCount);
    final var eventTriggerBehavior = new EventTriggerBehavior(zeebeState.getKeyGenerator(), catchEventBehavior, writers, zeebeState);
    final var eventPublicationBehavior = new BpmnEventPublicationBehavior(zeebeState, zeebeState.getKeyGenerator(), eventTriggerBehavior, writers);
    addDeploymentRelatedProcessorAndServices(catchEventBehavior, partitionId, zeebeState, typedRecordProcessors, deploymentResponder, expressionProcessor, writers, partitionsCount, actor, deploymentDistributor, zeebeState.getKeyGenerator());
    addMessageProcessors(eventTriggerBehavior, subscriptionCommandSender, zeebeState, typedRecordProcessors, writers);
    final var jobMetrics = new JobMetrics(partitionId);
    final TypedRecordProcessor<ProcessInstanceRecord> bpmnStreamProcessor = addProcessProcessors(zeebeState, expressionProcessor, typedRecordProcessors, subscriptionCommandSender, catchEventBehavior, eventTriggerBehavior, writers, timerChecker, jobMetrics);
    JobEventProcessors.addJobProcessors(typedRecordProcessors, zeebeState, onJobsAvailableCallback, eventPublicationBehavior, writers, jobMetrics, eventTriggerBehavior);
    addIncidentProcessors(zeebeState, bpmnStreamProcessor, typedRecordProcessors, writers, zeebeState.getKeyGenerator());
    return typedRecordProcessors;
}
Also used : VariableStateEvaluationContextLookup(io.camunda.zeebe.engine.processing.variable.VariableStateEvaluationContextLookup) MutableZeebeState(io.camunda.zeebe.engine.state.mutable.MutableZeebeState) BpmnEventPublicationBehavior(io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnEventPublicationBehavior) LogStream(io.camunda.zeebe.logstreams.log.LogStream) DueDateTimerChecker(io.camunda.zeebe.engine.processing.timer.DueDateTimerChecker) JobMetrics(io.camunda.zeebe.engine.metrics.JobMetrics) CatchEventBehavior(io.camunda.zeebe.engine.processing.common.CatchEventBehavior) TypedRecordProcessors(io.camunda.zeebe.engine.processing.streamprocessor.TypedRecordProcessors) ExpressionProcessor(io.camunda.zeebe.engine.processing.common.ExpressionProcessor) EventTriggerBehavior(io.camunda.zeebe.engine.processing.common.EventTriggerBehavior) ProcessInstanceRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord) DbMigrationController(io.camunda.zeebe.engine.state.migration.DbMigrationController)

Example 5 with ExpressionProcessor

use of io.camunda.zeebe.engine.processing.common.ExpressionProcessor in project zeebe by zeebe-io.

the class ZeebeRuntimeValidationTest method validate.

private static ValidationResults validate(final BpmnModelInstance model) {
    final ModelWalker walker = new ModelWalker(model);
    final ExpressionLanguage expressionLanguage = ExpressionLanguageFactory.createExpressionLanguage();
    final EvaluationContextLookup emptyLookup = scopeKey -> name -> null;
    final var expressionProcessor = new ExpressionProcessor(expressionLanguage, emptyLookup);
    final ValidationVisitor visitor = new ValidationVisitor(ZeebeRuntimeValidators.getValidators(expressionLanguage, expressionProcessor));
    walker.walk(visitor);
    return visitor.getValidationResult();
}
Also used : EvaluationContextLookup(io.camunda.zeebe.engine.processing.common.ExpressionProcessor.EvaluationContextLookup) ExpressionLanguageFactory(io.camunda.zeebe.el.ExpressionLanguageFactory) ValidationVisitor(io.camunda.zeebe.model.bpmn.validation.ValidationVisitor) Protocol(io.camunda.zeebe.protocol.Protocol) EvaluationContextLookup(io.camunda.zeebe.engine.processing.common.ExpressionProcessor.EvaluationContextLookup) StartEvent(io.camunda.zeebe.model.bpmn.instance.StartEvent) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) ExpectedValidationResult.expect(io.camunda.zeebe.engine.processing.deployment.model.validation.ExpectedValidationResult.expect) ArrayList(java.util.ArrayList) MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics) ZeebeOutput(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeOutput) ExpressionTransformer(io.camunda.zeebe.engine.processing.deployment.model.transformer.ExpressionTransformer) ModelWalker(io.camunda.zeebe.model.bpmn.traversal.ModelWalker) ZeebeSubscription(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeSubscription) ZeebeTaskHeaders(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeTaskHeaders) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) Assert.fail(org.junit.Assert.fail) Parameterized(org.junit.runners.Parameterized) Before(org.junit.Before) Iterator(java.util.Iterator) ZeebeAssignmentDefinition(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeAssignmentDefinition) Parameter(org.junit.runners.Parameterized.Parameter) ZeebeInput(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeInput) Test(org.junit.Test) Collectors(java.util.stream.Collectors) ExpressionProcessor(io.camunda.zeebe.engine.processing.common.ExpressionProcessor) ZeebeLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeLoopCharacteristics) List(java.util.List) ValidationResult(org.camunda.bpm.model.xml.validation.ValidationResult) ConditionExpression(io.camunda.zeebe.model.bpmn.instance.ConditionExpression) ExpressionLanguage(io.camunda.zeebe.el.ExpressionLanguage) ZeebeCalledElement(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeCalledElement) ValidationResults(org.camunda.bpm.model.xml.validation.ValidationResults) InputStream(java.io.InputStream) ValidationVisitor(io.camunda.zeebe.model.bpmn.validation.ValidationVisitor) ExpressionProcessor(io.camunda.zeebe.engine.processing.common.ExpressionProcessor) ModelWalker(io.camunda.zeebe.model.bpmn.traversal.ModelWalker) ExpressionLanguage(io.camunda.zeebe.el.ExpressionLanguage)

Aggregations

ExpressionProcessor (io.camunda.zeebe.engine.processing.common.ExpressionProcessor)11 ExpressionLanguage (io.camunda.zeebe.el.ExpressionLanguage)6 ExpressionLanguageFactory (io.camunda.zeebe.el.ExpressionLanguageFactory)6 Bpmn (io.camunda.zeebe.model.bpmn.Bpmn)6 BpmnModelInstance (io.camunda.zeebe.model.bpmn.BpmnModelInstance)6 ModelWalker (io.camunda.zeebe.model.bpmn.traversal.ModelWalker)6 ValidationVisitor (io.camunda.zeebe.model.bpmn.validation.ValidationVisitor)6 Collectors (java.util.stream.Collectors)6 ValidationResults (org.camunda.bpm.model.xml.validation.ValidationResults)6 JobMetrics (io.camunda.zeebe.engine.metrics.JobMetrics)5 BpmnEventPublicationBehavior (io.camunda.zeebe.engine.processing.bpmn.behavior.BpmnEventPublicationBehavior)5 CatchEventBehavior (io.camunda.zeebe.engine.processing.common.CatchEventBehavior)5 EventTriggerBehavior (io.camunda.zeebe.engine.processing.common.EventTriggerBehavior)5 TypedRecordProcessors (io.camunda.zeebe.engine.processing.streamprocessor.TypedRecordProcessors)5 DueDateTimerChecker (io.camunda.zeebe.engine.processing.timer.DueDateTimerChecker)5 DbMigrationController (io.camunda.zeebe.engine.state.migration.DbMigrationController)5 MutableZeebeState (io.camunda.zeebe.engine.state.mutable.MutableZeebeState)5 LogStream (io.camunda.zeebe.logstreams.log.LogStream)5 ProcessInstanceRecord (io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord)5 EvaluationContextLookup (io.camunda.zeebe.engine.processing.common.ExpressionProcessor.EvaluationContextLookup)4