Esempio n. 1
0
        public async Task send_message_to_and_receive_through_rabbitmq_with_named_topic()
        {
            var queueName = "messages4";

            var publisher = JasperHost.For(_ =>
            {
                _.Endpoints.ConfigureRabbitMq(x =>
                {
                    x.ConnectionFactory.HostName = "localhost";
                    x.DeclareExchange("topics", ex => { ex.ExchangeType = ExchangeType.Topic; });
                    x.DeclareQueue("messages4");
                    x.DeclareBinding(new Binding
                    {
                        BindingKey   = "special",
                        ExchangeName = "topics",
                        QueueName    = queueName
                    });

                    x.AutoProvision = true;
                });

                _.Endpoints.PublishAllMessages().ToRabbit("special", "topics");

                _.Handlers.DisableConventionalDiscovery();

                _.Extensions.UseMessageTrackingTestingSupport();
            });

            var receiver = JasperHost.For(_ =>
            {
                _.Endpoints.ConfigureRabbitMq(x =>
                {
                    x.ConnectionFactory.HostName = "localhost";
                });

                _.Endpoints.ListenToRabbitQueue(queueName);

                _.Extensions.UseMessageTrackingTestingSupport();

                _.Handlers.DisableConventionalDiscovery().IncludeType <SpecialTopicGuy>();
            });



            try
            {
                var message = new SpecialTopic();
                var session = await publisher.TrackActivity().AlsoTrack(receiver).SendMessageAndWait(message);


                var received = session.FindSingleTrackedMessageOfType <SpecialTopic>(EventType.MessageSucceeded);
                received
                .Id.ShouldBe(message.Id);
            }
            finally
            {
                publisher.Dispose();
                receiver.Dispose();
            }
        }
Esempio n. 2
0
        public async Task send_message_to_and_receive_through_rabbitmq_with_named_topic()
        {
            var uri = "rabbitmq://localhost/queue/messages4/topic/special";

            var publisher = JasperHost.For(_ =>
            {
                _.Settings.AddRabbitMqHost("localhost");
                _.Publish.AllMessagesTo(uri);
                _.Handlers.DisableConventionalDiscovery();
            });

            var receiver = JasperHost.For(_ =>
            {
                _.Settings.AddRabbitMqHost("localhost");

                _.Transports.ListenForMessagesFrom(uri);
                _.Services.AddSingleton <MessageTracker>();

                _.Handlers.DisableConventionalDiscovery().IncludeType <TracksMessage <SpecialTopic> >();
            });

            var wait = receiver.Get <MessageTracker>().WaitFor <SpecialTopic>();

            try
            {
                var message = new SpecialTopic();
                await publisher.Messaging.Send(message);

                var received = await wait;
                received.Message.ShouldBeOfType <SpecialTopic>()
                .Id.ShouldBe(message.Id);
            }
            finally
            {
                publisher.Dispose();
                receiver.Dispose();
            }
        }
Esempio n. 3
0
 public void Handle(SpecialTopic topic)
 {
 }