Exemplo n.º 1
0
        /// <summary>
        /// Handle an inbound message from a transport
        /// </summary>
        /// <param name="transportMessage">the raw message data and headers</param>
        /// <param name="endpoint">the endpoint the message came in on</param>
        /// <returns></returns>
        public Task Handle(TransportMessage transportMessage, IEndpoint endpoint)
        {
            InboundMessagePipeline messagePipeline = null;

            if (_endpointInboundPipeline.ContainsKey(endpoint))
            {
                messagePipeline = _endpointInboundPipeline[endpoint];
            }
            else
            {
                messagePipeline = new InboundMessagePipeline(endpoint.Settings.InboundTransportFilters, endpoint.Settings.InboundIntegrationFilters);
                _endpointInboundPipeline[endpoint] = messagePipeline;
            }

            var resultContext = messagePipeline.Process(new TransportMessageFilterContext(transportMessage, endpoint, FilterDirection.Inbound));

            if (resultContext.Message != null)
            {
                //immediate retry for transient failures
                return(_immediateHandleRetryPolicy.ExecuteAsync(() =>
                                                                _messageHandlerDispatcher.Dispatch(
                                                                    resultContext.Message,
                                                                    new MessageContext(resultContext.MessageMetaData, endpoint, this, resultContext.Props)
                                                                    )));
            }
            throw new ApplicationException($"Unable to handle message. MessageType: {transportMessage.MetaData?.MessageType}, Endpoint: {endpoint?.Name}");
        }
Exemplo n.º 2
0
        public void How_many_messages_can_the_pipe_send_per_second()
        {
            long count  = 0;
            long count2 = 0;
            long limit  = 2500000;

            var messageSink = new InstanceMessageSink <ClaimModified>(MultipleHandlerSelector.ForHandler(
                                                                          HandlerSelector.ForHandler <ClaimModified>(m => { count++; })));

            var messageSink2 = new InstanceMessageSink <ClaimModified>(MultipleHandlerSelector.ForHandler(
                                                                           HandlerSelector.ForHandler <ClaimModified>(m => { count2++; })));

            var router = new MessageRouter <IConsumeContext <ClaimModified> >();

            router.Connect(messageSink);
            router.Connect(messageSink2);


            var translater   = new InboundConvertMessageSink <ClaimModified>(router);
            var objectRouter = new MessageRouter <IConsumeContext>();

            objectRouter.Connect(translater);
            var pipeline = new InboundMessagePipeline(objectRouter, MockRepository.GenerateMock <IInboundPipelineConfigurator>());

            var message = new ClaimModified();
            var context = new ConsumeContext <ClaimModified>(ReceiveContext.Empty(), message);

            for (int i = 0; i < 100; i++)
            {
                pipeline.Dispatch(context);
            }

            count  = 0;
            count2 = 0;

            Stopwatch timer = Stopwatch.StartNew();

            for (int i = 0; i < limit; i++)
            {
                pipeline.Dispatch(context);
            }

            timer.Stop();

            Trace.WriteLine("Received: " + (count + count2) + ", expected " + limit * 2);
            Trace.WriteLine("Elapsed Time: " + timer.ElapsedMilliseconds + "ms");
            Trace.WriteLine("Messages Per Second: " + limit * 1000 / timer.ElapsedMilliseconds);
        }
Exemplo n.º 3
0
        protected bool Inspect(InboundMessagePipeline pipeline)
        {
            InsertAfter = (sink => pipeline.ReplaceOutputSink(sink));

            return(false);
        }
Exemplo n.º 4
0
        public bool Inspect(InboundMessagePipeline pipeline)
        {
            Append("Pipeline");

            return(true);
        }