Skip to content

Commit

Permalink
chore(correlation): fixed correct message ID fetching (#1233)
Browse files Browse the repository at this point in the history
  • Loading branch information
igpetrov authored Oct 6, 2023
1 parent 56abc55 commit 34a82ec
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public InboundCorrelationHandler(ZeebeClient zeebeClient, FeelEngineWrapper feel

public CorrelationResult<?> correlate(
InboundConnectorDefinitionImpl definition, Object variables) {
return correlate(definition, variables, UUID.randomUUID().toString());
return correlate(definition, variables, null);
}

public CorrelationResult<?> correlate(
Expand All @@ -69,7 +69,7 @@ public CorrelationResult<?> correlate(
msgCorPoint.messageName(),
msgCorPoint.correlationKeyExpression(),
variables,
messageId);
resolveMessageId(msgCorPoint.messageIdExpression(), messageId, variables));
}
if (correlationPoint instanceof MessageStartEventCorrelationPoint msgStartCorPoint) {
return triggerMessageStartEvent(definition, msgStartCorPoint, variables);
Expand All @@ -80,7 +80,8 @@ public CorrelationResult<?> correlate(
boundaryEventCorrelationPoint.messageName(),
boundaryEventCorrelationPoint.correlationKeyExpression(),
variables,
boundaryEventCorrelationPoint.messageIdExpression());
resolveMessageId(
boundaryEventCorrelationPoint.messageIdExpression(), messageId, variables));
}
throw new ConnectorException(
"Process correlation point "
Expand Down Expand Up @@ -137,7 +138,7 @@ protected CorrelationResult<CorrelatedMessageStart> triggerMessageStartEvent(
new CorrelationErrorData(CorrelationErrorReason.ACTIVATION_CONDITION_NOT_MET));
}

String messageId = extractMessageKey(correlationPoint, variables);
String messageId = extractMessageId(correlationPoint.messageIdExpression(), variables);
if (correlationPoint.messageIdExpression() != null
&& !correlationPoint.messageIdExpression().isBlank()
&& messageId == null) {
Expand Down Expand Up @@ -258,8 +259,7 @@ protected String extractCorrelationKey(String correlationKeyExpression, Object c
}
}

protected String extractMessageKey(MessageStartEventCorrelationPoint point, Object context) {
final String messageIdExpression = point.messageIdExpression();
protected String extractMessageId(String messageIdExpression, Object context) {
if (messageIdExpression == null || messageIdExpression.isBlank()) {
return "";
}
Expand All @@ -275,4 +275,15 @@ protected Object extractVariables(
return ConnectorHelper.createOutputVariables(
rawVariables, definition.resultVariable(), definition.resultExpression());
}

private String resolveMessageId(String messageId, String messageIdExpression, Object context) {
if (messageId == null) {
if (messageIdExpression != null) {
return extractMessageId(messageIdExpression, context);
} else {
return UUID.randomUUID().toString();
}
}
return messageId;
}
}

0 comments on commit 34a82ec

Please sign in to comment.