public async Task Handle(SubscribeContactMessage message, IMessageReceiveContext receiveContext, IMessageReplyContext replyContext)
        {
            Condition.Requires(message, "message").IsNotNull();
            Condition.Requires(receiveContext, "receiveContext").IsNotNull();
            Condition.Requires(replyContext, "replyContext").IsNotNull();
            var configuredTaskAwaitable = _deferStrategy.ExecuteAsync(_bus, message, receiveContext, () => SubscribeContact(message)).ConfigureAwait(false);

            if (!(await configuredTaskAwaitable).Deferred)
            {
                _logger.LogDebug("[SubscribeContactMessageHandler] processed message.'");
            }
            else
            {
                _logger.LogDebug("[SubscribeContactMessageHandler] deferred message.");
            }
        }
Пример #2
0
        public async Task Handle([NotNull] UnsubscribeMessage message, IMessageReceiveContext receiveContext, IMessageReplyContext replyContext)
        {
            Condition.Requires(message, nameof(message)).IsNotNull();
            Condition.Requires(receiveContext, nameof(receiveContext)).IsNotNull();
            Condition.Requires(replyContext, nameof(replyContext)).IsNotNull();

            DeferResult <HandlerResult> result = await _deferStrategy.ExecuteAsync(
                _bus,
                message,
                receiveContext,
                () => Unsubscribe(message)).ConfigureAwait(false);

            if (result.Deferred)
            {
                _logger.LogDebug($"[{nameof(UnsubscribeMessageHandler)}] defered message.");
            }
            else
            {
                _logger.LogDebug($"[{nameof(UnsubscribeMessageHandler)}] processed message.'");
            }
        }