<div dir="ltr"><p style="font-size: 13.600000381469727px; clear: both; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 17.804800033569336px;">I'm using different "Per Message TTL" in RabbitMQ queue, and I expect that messages with different TTL should be processed by consumer in due time.</p><p style="font-size: 13.600000381469727px; clear: both; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 17.804800033569336px;">To provide this behaviour, I use RabbitMQ queue with huge "x-message-ttl", I add messages to this queue with own value of "Per Message TTL"(see code below). For example add to queue messages with TTL 30, 20 and 10 seconds.</p><p style="font-size: 13.600000381469727px; clear: both; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 17.804800033569336px;">The problem in behaviour, how RabbitMQ process the messages with different "Per MessageTTL" in queue, the messages with largest TTL stop the messages with less TTL. So consumer process all mesages together, when largest TTL expire.</p><p style="font-size: 13.600000381469727px; clear: both; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 17.804800033569336px;"><br></p><p style="font-size: 13.600000381469727px; clear: both; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 17.804800033569336px;"><strong style="font-size: 13.600000381469727px; background-color: transparent;">Publish message code:</strong></p><pre class="lang-php prettyprint prettyprinted" style="margin-bottom: 10px; padding: 5px; font-size: 13.600000381469727px; background-color: rgb(238, 238, 238); font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; word-wrap: normal; color: rgb(0, 0, 0); line-height: 17.804800033569336px;"><code style="font-size: 13.600000381469727px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;"><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">$channel </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">=</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">new</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="typ" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(43, 145, 175);">AMQPChannel</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">$this</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">-></span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">connection</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">    
$exchange </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">=</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">new</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="typ" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(43, 145, 175);">AMQPExchange</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">$channel</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
$exchange</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">-></span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">setName</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">$exchangeName</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
$exchange</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">-></span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">setType</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">AMQP_EX_TYPE_DIRECT</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">        
$ttl </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">=</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> $ttl</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">*</span><span class="lit" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(128, 0, 0);">1000</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">;</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">    
$params </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">=</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> array</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="str" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(128, 0, 0);">'expiration'</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">=></span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">$ttl</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">    
$message </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">=</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> $exchange</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">-></span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">publish</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">$msg</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> $this</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">-></span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">queueNotDelayedName</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">null</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> $params</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span></code></pre><p style="font-size: 13.600000381469727px; clear: both; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 17.804800033569336px;"><br></p></div>