private async Task RePublishAsync(IMessage message, QueueReferences queueReferences, CancellationToken cancellationToken)
        {
            try
            {
                _logger.LogWarning("republishing message '{MessageId}' to topic '{Topic}' ...",
                                   message.Id, queueReferences.TopicName);

                await _publisher.PublishAsync(message, queueReferences.TopicName, cancellationToken : cancellationToken);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex,
                                 "an exception has occurred while publishing message '{MessageId}' to topic '{Topic}': {Exception}",
                                 message.Id,
                                 queueReferences.TopicName,
                                 ex.Message);
            }
        }
示例#2
0
        private async Task PublishAsyncCore(IMessage message, CancellationToken cancellationToken)
        {
            var queueRefs = _queueReferenceFactory.Create((dynamic)message);
            var result    = await _executor.PublishAsync(message, queueRefs.TopicName, cancellationToken : cancellationToken);

            if (result is null || result.Status == PersistenceStatus.NotPersisted)
            {
                throw new InvalidOperationException($"unable to publish message '{message.Id}'");
            }
        }