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); }
/// <inheritdoc/> public Task Execute(IntegrationMessage message, CancellationToken cancellationToken) { if (!_identityContext.HasAssociatedUser) { var userId = message.GetMetadata(UserIdMetadataKey); _logger.LogInformationIfEnabled( "Extracted {UserId} user id from message {MessageId}", userId, message.Id); if (!string.IsNullOrWhiteSpace(userId)) { _identityContext.SetUserId(userId); } } return Task.CompletedTask; }
/// <inheritdoc/> public Task Execute(IntegrationMessage message, CancellationToken cancellationToken) { if (!_identityContext.HasAssociatedTenant) { var tenantId = message .GetMetadata(TenantIdMetadataKey) .ToNullableLong(); _logger.LogInformationIfEnabled( "Extracted {TenantId} tenant id from message {MessageId}", tenantId, message.Id); if (tenantId.HasValue) { _identityContext.SetCurrentTenant(tenantId.Value); } } return(Task.CompletedTask); }