<div dir="ltr">A note of clarification, I was using values of 1, 3, 5, 10 milliseconds, not seconds, to give the server enough time to expire a 1 millisecond TTL on a message.  I discovered 10 milliseconds still wasn&#39;t always successful.  Regardless, I would expect to only have to sleep for 1 millisecond to give the sever enough time to remove a 1 millisecond TTL message.  Here&#39;s my example using the .Net API in which I&#39;m seeing about a 3% failure rate:<div>
<br></div><div><br></div><div><div>using System;</div><div>using System.Text;</div><div>using System.Threading;</div><div>using RabbitMQ.Client;</div><div>using RabbitMQ.Client.Framing.v0_9_1;</div><div><br></div><div>namespace RabbitTTLTest</div>
<div>{</div><div><span class="" style="white-space:pre">        </span>class Program</div><div><span class="" style="white-space:pre">        </span>{</div><div><span class="" style="white-space:pre">                </span>static void Main(string[] args)</div>
<div><span class="" style="white-space:pre">                </span>{</div><div><span class="" style="white-space:pre">                        </span>var messages = 0;</div><div><span class="" style="white-space:pre">                        </span>var iterations = 1000;</div><div>
<br></div><div><span class="" style="white-space:pre">                        </span>for (int i = 0; i &lt; iterations; i++)</div><div><span class="" style="white-space:pre">                                </span>messages += SendAndReceive();</div><div><br></div><div><span class="" style="white-space:pre">                        </span>Console.WriteLine(&quot;Received {0} messages&quot;, messages);</div>
<div><span class="" style="white-space:pre">                        </span>Console.WriteLine(&quot;API works {0}% of the time.&quot;, ((iterations - messages) / (decimal)iterations) * 100);</div><div><span class="" style="white-space:pre">                        </span>Console.WriteLine(&quot;Press any key to exit&quot;);</div>
<div><span class="" style="white-space:pre">                        </span>Console.ReadKey();</div><div><span class="" style="white-space:pre">                </span>}</div><div><br></div><div><span class="" style="white-space:pre">                </span>static int SendAndReceive()</div>
<div><span class="" style="white-space:pre">                </span>{</div><div><span class="" style="white-space:pre">                        </span>ProduceMessage();</div><div><span class="" style="white-space:pre">                        </span>Thread.Sleep(10);</div><div><span class="" style="white-space:pre">                        </span>return ConsumeMessage();</div>
<div><span class="" style="white-space:pre">                </span>}</div><div><br></div><div><span class="" style="white-space:pre">                </span>static int ConsumeMessage()</div><div><span class="" style="white-space:pre">                </span>{</div>
<div><span class="" style="white-space:pre">                        </span>int messages = 0;</div><div><span class="" style="white-space:pre">                        </span>var connectionFactory = new ConnectionFactory();</div><div><span class="" style="white-space:pre">                        </span>IConnection connection = connectionFactory.CreateConnection();</div>
<div><span class="" style="white-space:pre">                        </span>IModel channel = connection.CreateModel();</div><div><span class="" style="white-space:pre">                        </span>channel.QueueDeclare(&quot;sample-queue&quot;, false, false, false, null);</div>
<div><span class="" style="white-space:pre">                        </span>BasicGetResult result = channel.BasicGet(&quot;sample-queue&quot;, true);</div><div><span class="" style="white-space:pre">                        </span>if (result != null)</div><div><span class="" style="white-space:pre">                        </span>{</div>
<div><span class="" style="white-space:pre">                                </span>messages++;</div><div><span class="" style="white-space:pre">                                </span>string message = Encoding.UTF8.GetString(result.Body);</div><div><span class="" style="white-space:pre">                                </span>Console.WriteLine(message);</div>
<div><span class="" style="white-space:pre">                        </span>}</div><div><span class="" style="white-space:pre">                        </span>channel.Close();</div><div><span class="" style="white-space:pre">                        </span>connection.Close();</div><div>
<span class="" style="white-space:pre">                        </span>return messages;</div><div><span class="" style="white-space:pre">                </span>}</div><div><br></div><div><span class="" style="white-space:pre">                </span>static void ProduceMessage()</div>
<div><span class="" style="white-space:pre">                </span>{</div><div><span class="" style="white-space:pre">                        </span>var connectionFactory = new ConnectionFactory();</div><div><span class="" style="white-space:pre">                        </span>IConnection connection = connectionFactory.CreateConnection();</div>
<div><span class="" style="white-space:pre">                        </span>IModel channel = connection.CreateModel();</div><div><span class="" style="white-space:pre">                        </span>channel.QueueDeclare(&quot;sample-queue&quot;, false, false, false, null);</div>
<div><span class="" style="white-space:pre">                        </span>byte[] message = Encoding.UTF8.GetBytes(&quot;Hello, World!&quot;);</div><div><span class="" style="white-space:pre">                        </span>var properties = new BasicProperties();</div>
<div><span class="" style="white-space:pre">                        </span>properties.Expiration = &quot;1&quot;;</div><div><span class="" style="white-space:pre">                        </span>channel.BasicPublish(string.Empty, &quot;sample-queue&quot;, properties, message);</div>
<div><span class="" style="white-space:pre">                        </span>channel.Close();</div><div><span class="" style="white-space:pre">                        </span>connection.Close();</div><div><span class="" style="white-space:pre">                </span>}</div><div><span class="" style="white-space:pre">        </span>}</div>
<div>}</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 4, 2013 at 3:10 PM, Derek Greer <span dir="ltr">&lt;<a href="mailto:dbgreer@gmail.com" target="_blank">dbgreer@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Perhaps an important note, I&#39;m using the pull API which I&#39;m remembering doesn&#39;t create a &quot;consumer&quot;.<div>
<br></div><div>I&#39;ll pull together a small example and post it here.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Thu, Apr 4, 2013 at 2:48 PM, Michael Klishin <span dir="ltr">&lt;<a href="mailto:michael.s.klishin@gmail.com" target="_blank">michael.s.klishin@gmail.com</a>&gt;</span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div class="gmail_extra"><div>2013/4/4 Derek Greer <span dir="ltr">&lt;<a href="mailto:dbgreer@gmail.com" target="_blank">dbgreer@gmail.com</a>&gt;</span><br>

<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

No, I&#39;m seeing my consumer retrieve a message which should have been expired.</blockquote></div><div class="gmail_extra"><br></div></div><div class="gmail_extra">Derek,</div><br>Can you post a code example that reproduces the problem?<br>



<br clear="all"><div>Thanks.</div><span><font color="#888888">-- <br>MK<br><br><a href="http://github.com/michaelklishin" target="_blank">http://github.com/michaelklishin</a><br><a href="http://twitter.com/michaelklishin" target="_blank">http://twitter.com/michaelklishin</a><br>




</font></span></div></div>
<br></div></div><div class="im">_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
<br></div></blockquote></div><div class="im"><br><br clear="all"><div><br></div>-- <br><div><font face="georgia, serif" color="#c0c0c0">___________________________________________</font></div><font color="#333300" face="verdana, sans-serif"><span style><span style="color:rgb(51,51,0)">Derek Greer</span></span></font><div>

<a href="mailto:dbgreer@gmail.com" style="font-family:&#39;times new roman&#39;,serif" target="_blank">dbgreer@gmail.com</a><span style="color:rgb(51,51,255);font-family:&#39;times new roman&#39;,serif">     | </span><a href="http://twitter.com/derekgreer" style="font-family:&#39;times new roman&#39;,serif" target="_blank">@derekgreer</a>
</div><div><span style="color:rgb(51,51,255);font-family:&#39;times new roman&#39;,serif"><a href="http://derekgreer.lostechies.com/" target="_blank">lostechies.com</a></span><span style="color:rgb(51,51,255);font-family:&#39;times new roman&#39;,serif"> </span><span style="color:rgb(51,51,255);font-family:&#39;times new roman&#39;,serif">|</span><span style="color:rgb(51,51,255);font-family:&#39;times new roman&#39;,serif"> </span><font color="#3333ff"><font face="&#39;times new roman&#39;, serif"><a href="http://derekgreer.freshbrewedcode.com" target="_blank">freshbrewedcode.com</a> </font><span style="font-family:&#39;times new roman&#39;,serif">| <a href="http://aspiringcraftsman.com" target="_blank">aspiringcraftsman.com</a></span></font></div>

<div><div><div><span style="color:rgb(192,192,192);font-family:georgia,serif">___________________________________________</span><font color="#333300" face="georgia, serif"><br></font><div><div><div><font color="#666666" face="&#39;times new roman&#39;, serif"><br>

</font></div></div></div></div></div></div>
</div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><font face="georgia, serif" color="#c0c0c0">___________________________________________</font></div><font color="#333300" face="verdana, sans-serif"><span style="color:rgb(0,0,0)"><span style="color:rgb(51,51,0)">Derek Greer</span></span></font><div>
<a href="mailto:dbgreer@gmail.com" style="font-family:&#39;times new roman&#39;,serif" target="_blank">dbgreer@gmail.com</a><span style="color:rgb(51,51,255);font-family:&#39;times new roman&#39;,serif">     | </span><a href="http://twitter.com/derekgreer" style="font-family:&#39;times new roman&#39;,serif" target="_blank">@derekgreer</a>
</div><div><span style="color:rgb(51,51,255);font-family:&#39;times new roman&#39;,serif"><a href="http://derekgreer.lostechies.com/" target="_blank">lostechies.com</a></span><span style="color:rgb(51,51,255);font-family:&#39;times new roman&#39;,serif"> </span><span style="color:rgb(51,51,255);font-family:&#39;times new roman&#39;,serif">|</span><span style="color:rgb(51,51,255);font-family:&#39;times new roman&#39;,serif"> </span><font color="#3333ff"><font face="&#39;times new roman&#39;, serif"><a href="http://derekgreer.freshbrewedcode.com" target="_blank">freshbrewedcode.com</a> </font><span style="font-family:&#39;times new roman&#39;,serif">| <a href="http://aspiringcraftsman.com" target="_blank">aspiringcraftsman.com</a></span></font></div>
<div><div><div><span style="color:rgb(192,192,192);font-family:georgia,serif">___________________________________________</span><font color="#333300" face="georgia, serif"><br></font><div><div><div><font color="#666666" face="&#39;times new roman&#39;, serif"><br>
</font></div></div></div></div></div></div>
</div>