使用Laravel在AWS上设置SQS消息队列

时间:2018-09-10 09:23:29

标签: php laravel message-queue amazon-sqs beanstalkd

我们正在将现有应用程序从Linode迁移到AWS。在Linode上,我们使用beanstalkd作为消息队列,现在我们想尝试SQS。我们使用2个队列:默认队列和高队列。我们对beantalkd的配置设置如下:

'connections' => [

    'beanstalkd' => [
        'driver' => 'beanstalkd',
        'host' => env('BEANSTALKD_HOST', 'localhost'),
        'queue' => 'default',
        'retry_after' => 86400,
    ],

    'high' => [
        'driver' => 'beanstalkd',
        'host' => env('BEANSTALKD_HOST', 'localhost'),
        'queue' => 'high',
        'retry_after' => 86400,
    ],
],

我现在正在尝试在AWS上做类似的事情。现在的配置如下所示:

'connections' => [
    'sqs' => [
        'driver' => 'sqs',
        'key' => env('AWS_KEY'),
        'secret' => env('AWS_SECRET'),
        'prefix' => env('AWS_SQS_URL'),
        'queue' => 'default',
        'region' => env('AWS_REGION'),
    ],

    'high' => [
        'driver' => 'sqs',
        'key' => env('AWS_KEY'),
        'secret' => env('AWS_SECRET'),
        'prefix' => env('AWS_SQS_URL'),
        'queue' => 'high',
        'region' => env('AWS_REGION'),
    ],        
],

我在AWS上创建了一个名为'dev'的队列,并且拥有以下URL:https://sqs.eu-west-2.amazonaws.com/ACCOUNT-ID/dev我得到的错误是:

Error executing "ReceiveMessage" on "https://sqs.eu-west-2.amazonaws.com/ACCOUNT-ID/dev/high"; AWS HTTP error: Client error: `POST https://sqs.eu-west-2.amazonaws.com/ACCOUNT-ID/dev/high` resulted in a `400 Bad Request` response:
<?xml version="1.0"?><ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><Error><Type>Sender</Type><Code>A (truncated...)
 AWS.SimpleQueueService.NonExistentQueue (client): The specified queue does not exist for this wsdl version. - <?xml version="1.0"?><ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><Error><Type>Sender</Type><Code>AWS.SimpleQueueService.NonExistentQueue</Code><Message>The specified queue does not exist for this wsdl version.</Message><Detail/></Error><RequestId>REQUEST-ID</RequestId></ErrorResponse>

它说“指定的队列不存在”。我应该在AWS中创建其他队列还是我的配置有问题?

主管配置:

[program:worker]
command=php /home/dev/default/current/artisan queue:work sqs --sleep=0 --daemon --quiet --timeout=0 --delay=3 --tries=3 --env=development --queue="high,default"

process_name=%(program_name)s_%(process_num)02d
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=dev
numprocs=8
stdout_logfile=

1 个答案:

答案 0 :(得分:1)

对不起,您的回复很晚。我在Google上搜索了同样的问题,然后发现了这个问题。

网址应为 https://sqs.eu-west-2.amazonaws.com/your-account-id。网址后没有queue name。因此,您需要从网址中删除dev

谢谢