Queues managed by the RabbitMQ federated plugin cannot be deleted as the plugin performs periodic topology checks and re-creates the deleted queues. This is true even if you set a queue TTL because it takes effect only in the absence of consumers and queue federated links.
To work around these constraints, you can set a temporary policy to disable the federation on the specific queue before deleting it. The steps are outline below, with an example.
1. Stop producers/consumers on the queue.
2. Add a higher-priority temporary policy, with a 'regular expression' that selects only the queues in question, and specifies a non-existing federation upstream. This will disable federation on that queue.
For example,
rabbitmqadmin --host=localhost --port=15672 declare policy name=fed-policy pattern=‘^test-queue-0$$' definition='{"federation-upstream":"undefined"}' priority=10 apply-to=queues
rabbitmqadmin --host=localhost --port=15673 declare policy name=fed-policy pattern='^test-queue-0$$' definition='{"federation-upstream":"undefined"}' priority=10 apply-to=queues
3. Delete the queues as shown in the example below.
rabbitmqadmin --host=localhost --port=15672 delete queue name=test-queue-0
rabbitmqadmin --host=localhost --port=15673 delete queue name=test-queue-0
4. Delete the temporary policy
rabbitmqadmin --host=localhost --port=15672 delete policy name=fed-policy
rabbitmqadmin --host=localhost --port=15673 delete policy name=fed-policy
In this example, we have used the rabbitmqadmin tool. You can also create a custom app using an http api client. More information can be found in the links below.
https://www.rabbitmq.com/management.html#http-api
https://rawcdn.githack.com/rabbitmq/rabbitmq-server/v3.11.17/deps/rabbitmq_management/priv/www/api/index.html
Please note that direct access to queues from an app is possible only with federated queues and not queues managed by federated exchanges.