我需要用redis
经纪人替换我的SQS
经纪人,在谷歌时,我遇到了很多页面,告诉我如何将SQS
与celery
一起使用。根据我的理解,它创建自己的SQS队列,我只有一个任务,并希望使用已经创建的SQS队列。
答案 0 :(得分:5)
默认情况下,如果已定义,celery将使用a Queue Prefix设置为您创建新队列。
但是,如果要使用现有队列,可以使用task-default-queue
设置提供名称。在这种情况下,请确保您没有定义上面提到的队列前缀。
答案 1 :(得分:1)
您可以通过broker_transport_options
(在芹菜4.0中)设置队列名称,如:
broker_transport_options = {"queue_name_prefix": "my-queue-"}
文档为here
答案 2 :(得分:0)
commit on 26th Feb(2020年)增加了使用预定义队列的功能。
通过向CELERY_BROKER_TRANSPORT_OPTIONS添加预定义的队列选项,您应该能够使用预定义的队列
CELERY_BROKER_TRANSPORT_OPTIONS={
'predefined_queues':{
'HIGH_PRIORITY': {
'url': 'https://sqs.ap-south-1.amazonaws.com/030221/HGH_PRIORITY',
'access_key_id': config('AWS_ACCESS_KEY'),
'secret_access_key': config('AWS_SECRET_KEY'),
},
}
}
以下是该提交的文档更新-
Other Features supported by this transport:
Predefined Queues:
The default behavior of this transport is to use a single AWS credential
pair in order to manage all SQS queues (e.g. listing queues, creating
queues, polling queues, deleting messages).
If it is preferable for your environment to use a single AWS credential, you
can use the 'predefined_queues' setting inside the 'transport_options' map.
This setting allows you to specify the SQS queue URL and AWS credentials for
each of your queues. For example, if you have two queues which both already
exist in AWS) you can tell this transport about them as follows:
transport_options = {
'predefined_queues': {
'queue-1': {
'url': 'https://sqs.us-east-1.amazonaws.com/xxx/aaa',
'access_key_id': 'a',
'secret_access_key': 'b',
},
'queue-2': {
'url': 'https://sqs.us-east-1.amazonaws.com/xxx/bbb',
'access_key_id': 'c',
'secret_access_key': 'd',
},
}
}