public void SynchronousRPC() { LOG.Info("Starting SynchronousRPC"); var requestExchange = "SynchronousRPC"; var requestRoutingKey = "SynchronousRPCRoutingKey"; var requestQueue = "SynchronousRPCQueue"; var requestListenerName = "SynchronousRPCListener"; _topicBus.ExchangeDeclare(requestExchange, "direct", false, false); _topicBus.QueueDeclare(requestQueue, false, false, false); _topicBus.QueueBind(requestQueue, requestExchange, requestRoutingKey); TextMessage textMessage = new TextMessage() { ContextID = Guid.NewGuid().ToString(), From = "Me", To = "You", Text = "Hello world" }; _topicBus.CreateListener(requestListenerName, requestQueue, true, (Func <TextMessage, TextMessage>)((TextMessage message) => { Thread.Sleep(2000); return(message); })); var response = _topicBus.SendAndReceive(requestExchange, requestRoutingKey, textMessage) as TextMessage; Assert.IsTrue(response != null, "Return result not received"); LOG.Info("Ending SynchronousRPC"); }
public bool ExchangeDeclare(string exchangeName, string exchangeType, bool durable, bool autoDelete) { if (_topicBus == null) { throw new ApplicationException("DynamicTopicBus wraps a ITopicBus instance that as not been set."); } return(_topicBus.ExchangeDeclare(exchangeName, exchangeType, durable, autoDelete)); }