Пример #1
0
        public async Task TestCorrelationNotCopiedFromRequestMessgeIdIfAlreadySetByHandler()
        {
            IMessage message          = Message.Create("test");
            var      inputChannel     = new DirectChannel(provider.GetService <IApplicationContext>());
            var      outputChannel    = new QueueChannel(provider.GetService <IApplicationContext>(), 1);
            var      serviceActivator = new ServiceActivatingHandler(provider.GetService <IApplicationContext>(), new TestBeanCreateMessage());

            serviceActivator.OutputChannel = outputChannel;
            var endpoint = new EventDrivenConsumerEndpoint(provider.GetService <IApplicationContext>(), inputChannel, serviceActivator);
            await endpoint.Start();

            Assert.True(inputChannel.Send(message));
            var reply    = outputChannel.Receive(0);
            var accessor = new IntegrationMessageHeaderAccessor(reply);

            Assert.Equal("456-XYZ", accessor.GetCorrelationId());
        }
Пример #2
0
        public async Task TestCorrelationNotPassedFromRequestHeaderIfAlreadySetByHandler()
        {
            object correlationId    = "123-ABC";
            var    message          = Support.IntegrationMessageBuilder.WithPayload("test").SetCorrelationId(correlationId).Build();
            var    inputChannel     = new DirectChannel(provider.GetService <IApplicationContext>());
            var    outputChannel    = new QueueChannel(provider.GetService <IApplicationContext>(), 1);
            var    serviceActivator = new ServiceActivatingHandler(provider.GetService <IApplicationContext>(), new TestBeanCreateMessage());

            serviceActivator.OutputChannel = outputChannel;
            var endpoint = new EventDrivenConsumerEndpoint(provider.GetService <IApplicationContext>(), inputChannel, serviceActivator);
            await endpoint.Start();

            Assert.True(inputChannel.Send(message));
            var reply    = outputChannel.Receive(0);
            var accessor = new IntegrationMessageHeaderAccessor(reply);

            Assert.Equal("456-XYZ", accessor.GetCorrelationId());
        }
Пример #3
0
        public async Task TestCorrelationIdPassedIfAvailable()
        {
            object correlationId    = "123-ABC";
            var    message          = Support.MessageBuilder.WithPayload("test").SetCorrelationId(correlationId).Build();
            var    inputChannel     = new DirectChannel(provider);
            var    outputChannel    = new QueueChannel(provider, 1);
            var    serviceActivator = new ServiceActivatingHandler(provider, new TestBeanUpperCase());

            serviceActivator.OutputChannel = outputChannel;
            var endpoint = new EventDrivenConsumerEndpoint(provider, inputChannel, serviceActivator);
            await endpoint.Start();

            Assert.True(inputChannel.Send(message));
            var reply    = outputChannel.Receive(0);
            var accessor = new IntegrationMessageHeaderAccessor(reply);

            Assert.Equal(correlationId, accessor.GetCorrelationId());
        }