public void A_response_should_be_sent_directly_if_a_reply_address_is_specified() { var ping = new PingMessage(); var otherConsumer = new TestMessageConsumer <PongMessage>(); RemoteBus.SubscribeInstance(otherConsumer); var consumer = new TestCorrelatedConsumer <PongMessage, Guid>(ping.CorrelationId); LocalBus.SubscribeInstance(consumer); var pong = new FutureMessage <PongMessage>(); RemoteBus.SubscribeHandler <PingMessage>(message => { pong.Set(new PongMessage(message.CorrelationId)); RemoteBus.Context().Respond(pong.Message); }); RemoteBus.ShouldHaveRemoteSubscriptionFor <PongMessage>(); LocalBus.ShouldHaveRemoteSubscriptionFor <PongMessage>(); LocalBus.ShouldHaveRemoteSubscriptionFor <PingMessage>(); LocalBus.Publish(ping, context => context.SendResponseTo(LocalBus)); Assert.IsTrue(pong.IsAvailable(8.Seconds()), "No pong generated"); consumer.ShouldHaveReceivedMessage(pong.Message, 8.Seconds()); otherConsumer.ShouldNotHaveReceivedMessage(pong.Message, 1.Seconds()); }
public void A_pong_service() { PingService = new ConsumerOf <Ping>(ping => { // Response with a pong to the ping RemoteBus.Context().Respond(new Pong(ping.CorrelationId)); }); RemoteBus.SubscribeInstance(PingService); }