Hey guys, I'm new to RabbitMQ and am having trouble finding the answer to this question on Google, so please forgive me if this is old hat.<div><br></div><div>I'm trying to setup a request/response queue with a TTL on the request messages. �My client is only going wait 500ms for a response. �If the client does not get a response in 500ms it's going to bail. �Because of this, there's no reason for the server to handle messages that have been in the queue for longer than 500ms.</div>
<div><br></div><div>I've setup a simple test case using SimpleRpcClient and SimpleRpcServer. �Everything works except message expiration. �All requests sent to the queue are processed by the server code, regardless of how long they sat in the queue. �I could, of course, add a timestamp to my message and handle filter them manually, but I was hoping the RabbitMQ infrastructure could do this for me. �</div>
<div><br></div><div>Here's the client code (C#):</div><div><br></div><div><div>var connectionFactory = new ConnectionFactory();</div><div><br></div><div>using (var connection = connectionFactory.CreateConnection("127.0.0.1"))</div>
<div>using (var model = connection.CreateModel())</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>model.ExchangeDeclare("TestExchange", ExchangeType.Direct);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>model.QueueDeclare("TestQueue");</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>model.QueueBind("TestQueue", "TestExchange", "TestRoute", false, null);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>var client = new SimpleRpcClient(model, "TestExchange", "TestQueue", "TestRoute");</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>client.TimeoutMilliseconds = 500;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>var request = Guid.NewGuid().ToString("N");</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>var requestData = Encoding.UTF32.GetBytes(request);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>var requestProperties = model.CreateBasicProperties();</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>requestProperties.Expiration = "1000";</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>var responseData = client.Call(requestProperties, requestData);</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if (responseData == null)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>Console.Out.WriteLine("{0}: Timed Out", request);</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>else</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>Console.Out.WriteLine("{0}: {1}", request, Encoding.UTF32.GetString(responseData.Body));</div>
<div>}</div><div><br></div><div>Thanks,</div><div>Bryan</div></div>