Why aren't my rabbit lines dying?

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 |  // Don't care; no delete possible
| false       | false     | true  |  // Don't care; no delete possible
| false       | true      | false |
| false       | true      | true  |
| true        | false     | false |  // Fails consumer requirement
| 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, "");

// Populate MainQueue with several calls of: channel.BasicPublish(MainExchange, "", null, body);
// ...

// Pull a message
BasicGetResult result = channel.BasicGet(MainQueue, false);

// Logic for requeueing; Foo is my work task class
    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}
    };

    // Set auto delete or not here
    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);

//Acknowledge original message pulled from MainQueue
channel.BasicAck(result.DeliveryTag, false);        
+4
1

"MainQueue" , 4- , autoDelete = false. :

QueueDeclareOk QueueDeclare (string queue, bool durable, bool exclusive, bool autoDelete, IDictionary arguments);

, , :

channel.QueueDeclare(MainQueue, true, true, true, null);

retryQueue "x-message-ttl", , . , , 30 , . "x-expires" , AFAIK . , 30 , , queueArgs .

Dictionary<string, object> queueArgs = new Dictionary<string, object>
{
    {"x-dead-letter-exchange", MainExchange},
    {"x-expires", messageRequeueTTL} 
};

channel.QueueDeclare(retryQueue, false, false, false, queueArgs);

: https://www.rabbitmq.com/ttl.html

+3

All Articles