Пример #1
0
 public Task <object> Any(AnyTestMqAsync request)
 {
     return(Task.Factory.StartNew(() =>
                                  new AnyTestMqResponse {
         CorrelationId = request.Id
     } as object));
 }
        public void Can_Publish_to_AnyTestMqAsync_Service()
        {
            using (var mqFactory = appHost.TryResolve <IMessageFactory>())
            {
                var request = new AnyTestMqAsync {
                    Id = 1
                };

                using (var mqProducer = mqFactory.CreateMessageProducer())
                    mqProducer.Publish(request);

                using (var mqClient = mqFactory.CreateMessageQueueClient())
                {
                    var msg = mqClient.Get <AnyTestMqResponse>(QueueNames <AnyTestMqResponse> .In, null);
                    mqClient.Ack(msg);
                    Assert.That(msg.GetBody().CorrelationId, Is.EqualTo(request.Id));
                }
            }
        }