public Task Execute(IntegrationMessage message, CancellationToken cancellationToken) { var wcDoesNotHaveOperationContext = !_workloadContext.Contains(OperationContext.MetaName); var messageHasOperationContext = message.HasMetadata(OperationContext.MetaName); if (messageHasOperationContext && wcDoesNotHaveOperationContext) { var messageOperationContext = message.GetMetadata(OperationContext.MetaName); var operationContext = OperationContext.Unpack(messageOperationContext); _logger.LogInformationIfEnabled( "Extracted operation context with {OperationContextId} id and '{OperationContextPath}' path from message {MessageId}", operationContext.CorrelationId, operationContext.GetDescription(), message.Id); var messageName = message.GetMessageName(); var currentOperationPart = new OperationPart($"{messageName}_Handler"); _logger.LogInformationIfEnabled( "Updating operation context with {OperationContextId} id and '{OperationContextPath}' path extracted from message {MessageId} with '{OperationPart}' operation part", operationContext.CorrelationId, operationContext.GetDescription(), message.Id, currentOperationPart.Name); operationContext.Add(currentOperationPart); _logger.LogInformationIfEnabled( "Updated operation context with {OperationContextId} id and '{OperationContextPath}' path extracted from message {MessageId}", operationContext.CorrelationId, operationContext.GetDescription(), message.Id); _workloadContext.AddItem(OperationContext.MetaName, operationContext); _logger.LogInformationIfEnabled( "Saved operation context with {OperationContextId} id and '{OperationContextPath}' path extracted from message {MessageId} into workload context", operationContext.CorrelationId, operationContext.GetDescription(), message.Id); } return(Task.CompletedTask); }
public ExtractOperationContextFromMessageMetadataStepFixture SetupWorkloadContextToContainOperationCtx() { WorkloadContext.AddItem(OperationContext.MetaName, FakeOperationContext); return(this); }