Nazil Khan
Nazil Khan

Reputation: 147

Celery Worker - Consume from Queue matching a regex

Background

Celery worker can be started against a set of queues using -Q flag. E.g.

-Q dev.Q1,dev.Q2,dev.Q3

So far I have seen examples where all the queue names are explicitly listed as comma separated values. It is troublesome if I have a very long list.

Question

Is there a way I can specify queue names as a regex & celery worker will start consuming from all queues satisfying that regex.

E.g.

-Q dev.*

This should consume from all queuess starting with dev i.e. dev.Q1, dev.Q2, dev.Q3. But what I have seen is - it creates a queue dev..*

Also how can I tune the regex so that it doesn't pick ERROR queues e.g. dev.Q1.ERROR, dev.Q2.ERROR.

Upvotes: 5

Views: 618

Answers (1)

vince
vince

Reputation: 8306

Something along these lines would work: (\b(dev.)(\w+)). Then refer to the second group for the stuff after "dev.".

You'll need to set it up to capturing repeated instances if you want to get multiple.

Upvotes: -2

Related Questions