コード例 #1
0
        public async Task Consume(ConsumeContext <WebToGateway> context)
        {
            ConsoleHelper.WriteLine($"Gateway received request to process message named '{context.Message.Name}'", ConsoleColor.Green);
            ConsoleHelper.WriteLine("Message GUID: " + context.Message.CorrelationId, ConsoleColor.Green);

            var downwardsMessage = new SpecificReportGatewayToFarm()
            {
                OriginalRequest = context.Message, CorrelationId = context.Message.CorrelationId
            };
            var uriExchange = new Uri("rabbitmq://localhost:5672/ZZ_Gateway_To_Farm_Queue");

            await context.Forward(uriExchange, downwardsMessage);
        }
コード例 #2
0
        async Task MessageRedeliveryContext.ScheduleRedelivery(TimeSpan delay, Action <ConsumeContext, SendContext> callback)
        {
            IPipe <SendContext <TMessage> > pipe = Pipe.Execute <SendContext <TMessage> >(sendContext =>
            {
                sendContext.Headers.Set(MessageHeaders.RedeliveryCount, _context.GetRedeliveryCount() + 1);

                callback?.Invoke(_context, sendContext);
            });

            IPipe <SendContext <TMessage> > delaySendPipe = new DelaySendPipe <TMessage>(pipe, delay);

            var schedulerEndpoint = await _context.GetSendEndpoint(_context.ReceiveContext.InputAddress).ConfigureAwait(false);

            await _context.Forward(schedulerEndpoint, delaySendPipe).ConfigureAwait(false);
        }
コード例 #3
0
        public async Task Consume(ConsumeContext <Fault <PayOrderEvent> > context)
        {
            var retryCount = context.GetRetryCount();

            if (retryCount == 5)
            {
                if (EndpointConvention.TryGetDestinationAddress <PayOrderEvent>(out Uri endPointUrl))
                {
                    await context.Forward(endPointUrl);
                }
            }
            else
            {
                var exceptions = context.Message.Exceptions;

                foreach (var exceptionInfo in exceptions)
                {
                    await Execute(context, exceptionInfo);
                }
            }
        }