Exemple #1
0
        public void Can_publish_and_receive_messages_with_MessageFactory()
        {
            using (var mqFactory = new RabbitMqMessageFactory(Config.RabbitMQConnString))
                using (var mqClient = mqFactory.CreateMessageQueueClient())
                {
                    mqClient.Publish(new Hello {
                        Name = "Foo"
                    });
                    var msg = mqClient.Get <Hello>(QueueNames <Hello> .In);

                    Assert.That(msg.GetBody().Name, Is.EqualTo("Foo"));
                }
        }
        public void Can_Send_Email_via_MqClient()
        {
            var mqFactory = new RabbitMqMessageFactory();

            using (var mqClient = mqFactory.CreateMessageQueueClient())
            {
                mqClient.Publish(new EmailContact {
                    ContactId = 1, Subject = "UnitTest MQ Email #1", Body = "Body 1"
                });
                mqClient.Publish(new EmailContact {
                    ContactId = 1, Subject = "UnitTest MQ Email #2", Body = "Body 2"
                });
            }
        }
Exemple #3
0
        [Test] // requires running Host MQ Server project
        public void Can_send_Request_Reply_message()
        {
            using (var mqClient = MqFactory.CreateMessageQueueClient())
            {
                var replyToMq = mqClient.GetTempQueueName();

                mqClient.Publish(new Message <Hello>(new Hello {
                    Name = "MQ Worker"
                })
                {
                    ReplyTo = replyToMq,
                });

                var responseMsg = mqClient.Get <HelloResponse>(replyToMq);
                mqClient.Ack(responseMsg);
                Assert.That(responseMsg.GetBody().Result, Is.EqualTo("Hello, MQ Worker!"));
            }
        }
        public void Allows_MegaDto_through_RabbitMqClients()
        {
            var mqFactory = new RabbitMqMessageFactory(connectionString: Config.RabbitMQConnString);

            var request = MegaDto.Create();

            using (var mqClient = mqFactory.CreateMessageProducer())
            {
                mqClient.Publish(request);
            }

            using (var mqClient = mqFactory.CreateMessageQueueClient())
            {
                var msg      = mqClient.Get <MegaDto>(QueueNames <MegaDto> .In);
                var response = msg.GetBody();

                Assert.That(request.T01.Id, Is.EqualTo(response.T01.Id));
            }
        }