I have a problem with my RabbitMQ queues expiring.
I am using RabbitMQ 3.2.4; The server runs on Windows, and my client code is in C #.
I tried to set the auto delete queue option and TTL queue value through x-expire. I tried loading the dummy message queue in order to fake the appearance of the consumer, and I even tried to change the exchange portability parameter.
Of the five possible combinations, none of them leads to the removal of the queue. I waited for hours (days?) After closing the last connection, but the queues do not disappear.
| auto-delete | x-expires | Prime |
| ----------- | --------- | ----- |
| false | false | false |
| false | false | true |
| false | true | false |
| false | true | true |
| true | false | false |
| true | false | true |
| true | true | false |
| true | true | true |
The queue will not be automatically deleted if it did not have at least one consumer, otherwise the queue could be automatically deleted immediately after the announcement.
/ , ?
, XY, . , . , ; ; . , . , , .
// , , RabbitMQ dead-letter-exchange , . :
, .
, .
, , . , .
.
priming, , a BasicPublish, BasicGet
private ConnectionFactory factory;
private IConnection connection;
private IModel channel;
private static string MainExchange = "MainExchange";
private static string RetryExchange = "RetryExchange";
private static string MainQueue = "MainQueue";
private static int messageRequeueTTL = 30000;
private static int requeueQueueTTL = messageRequeueTTL + 15000;
factory = new ConnectionFactory() { ... }
connection = factory.CreateConnection();
channel = connection.CreateModel();
channel.ExchangeDeclare(MainExchange, ExchangeType.Topic, true);
channel.ExchangeDeclare(RetryExchange, ExchangeType.Headers, false);
channel.QueueDeclare(MainQueue, true, false, false, null);
channel.QueueBind(MainQueue, MainExchange, "");
BasicGetResult result = channel.BasicGet(MainQueue, false);
string retryQueue = CreateRequeueName(foo.ID);
Dictionary<string, object> queueArgs = new Dictionary<string, object>
{
{"x-dead-letter-exchange", MainExchange}
,{"x-message-ttl", messageRequeueTTL}
};
Dictionary<string, object> bindArgs = new Dictionary<string, object>
{
{"x-match", "all"}
,{"key1", foo.ID}
,{"x-expires", requeueQueueTTL}
};
channel.QueueDeclare(retryQueue, false, false, false, queueArgs);
channel.QueueBind(retryQueue, RetryExchange, "", bindArgs);
PrimeRetryQueue(foo.ID);
var body = Encoding.UTF8.GetBytes(Foo.ToXML(foo));
var props = channel.CreateBasicProperties();
props.Headers = new Dictionary<string, object>() { { "key1", foo.ID } };
channel.BasicPublish(RetryExchange, "", props, body);
channel.BasicAck(result.DeliveryTag, false);