示例#1
0
        public void RequestResponseSaga_should_make_a_request_get_the_response_and_end()
        {
            new RequestResponseSaga().Initialize(bus);

            const string text         = "some text";
            var          startMessage = new StartMessage {
                Text = text
            };

            // imitate the responding service
            bus.Respond <TestRequestMessage, TestResponseMessage>(request =>
                                                                  new TestResponseMessage {
                Text = request.Text
            });

            // set up the subscription for the end message
            EndMessage endMessage = null;

            bus.Subscribe <EndMessage>("id", end =>
            {
                endMessage = end;
            });

            // now publish the start message to kick the saga off
            bus.Publish(startMessage);

            // assert that the end message was assigned and has the correct text
            Assert.IsNotNull(endMessage);
            Assert.AreEqual(text, endMessage.Text);
        }
示例#2
0
        public void RequestResponseSaga_should_make_a_request_get_the_response_and_end()
        {
            new RequestResponseSaga().Initialize(bus);

            const string text = "some text";
            var startMessage = new StartMessage {Text = text};

            // imitate the responding service
            bus.Respond<TestRequestMessage, TestResponseMessage>(request =>
                new TestResponseMessage { Text = request.Text });

            // set up the subscription for the end message
            EndMessage endMessage = null;
            bus.Subscribe<EndMessage>("id", end =>
            {
                endMessage = end;
            });

            // now publish the start message to kick the saga off
            bus.Publish(startMessage);

            // assert that the end message was assigned and has the correct text
            Assert.IsNotNull(endMessage);
            Assert.AreEqual(text, endMessage.Text);
        }
示例#3
0
        /// <summary>
        /// Run both EasyNetQ.Tests.SimpleSaga and EasyNetQ.Tests.SimpleService first
        /// You should see the message hit the SimpleSaga, bounce to the SimpleService
        /// and then bounce back to the SimpleSaga again before ending here.
        /// </summary>
        public void RunSaga()
        {
            var bus = RabbitHutch.CreateBus("host=localhost");

            bus.Subscribe<EndMessage>("runSaga_spike", endMessage =>
                Console.WriteLine("Got EndMessage: {0}", endMessage.Text));

            var startMessage = new StartMessage
            {
                Text = "Hello Saga! "
            };

            bus.Publish(startMessage);

            // give the message time to run through the process
            Thread.Sleep(1000);
        }
示例#4
0
        /// <summary>
        /// Run both EasyNetQ.Tests.SimpleSaga and EasyNetQ.Tests.SimpleService first
        /// You should see the message hit the SimpleSaga, bounce to the SimpleService
        /// and then bounce back to the SimpleSaga again before ending here.
        /// </summary>
        public void RunSaga()
        {
            var bus = RabbitHutch.CreateBus("host=localhost");

            bus.Subscribe <EndMessage>("runSaga_spike", endMessage =>
                                       Console.WriteLine("Got EndMessage: {0}", endMessage.Text));

            var startMessage = new StartMessage
            {
                Text = "Hello Saga! "
            };

            bus.Publish(startMessage);

            // give the message time to run through the process
            Thread.Sleep(1000);
        }
示例#5
0
        /// <summary>
        /// Run both EasyNetQ.Tests.SimpleSaga and EasyNetQ.Tests.SimpleService first
        /// You should see the message hit the SimpleSaga, bounce to the SimpleService
        /// and then bounce back to the SimpleSaga again before ending here.
        /// </summary>
        public void RunSaga()
        {
            var autoResetEvent = new AutoResetEvent(false);
            var bus            = RabbitHutch.CreateBus("host=localhost");

            bus.Subscribe <EndMessage>("runSaga_spike", endMessage =>
            {
                Console.WriteLine("Got EndMessage: {0}", endMessage.Text);
                autoResetEvent.Set();
            });

            var startMessage = new StartMessage
            {
                Text = "Hello Saga! "
            };

            using (var publishChannel = bus.OpenPublishChannel())
            {
                publishChannel.Publish(startMessage);
            }

            // give the message time to run through the process
            autoResetEvent.WaitOne(1000);
        }