带有 Amazon SQS 的 Laravel 队列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21950752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 09:04:28  来源:igfitidea点击:

Laravel Queue with Amazon SQS

laravelamazon-web-servicesqueueamazon-sqs

提问by Prosenjit

Hi I am new in laravel 4, getting trouble while configuring AWS SQS in my local machine. I need to push some jobs in the AWS queue and execute them sequentially.

嗨,我是 laravel 4 的新手,在我的本地机器上配置 AWS SQS 时遇到问题。我需要在 AWS 队列中推送一些作业并按顺序执行它们。

I have set the required values in app/config/queue.php

我已经在app/config/queue.php 中设置了所需的值

 'sqs' => array(
     'driver' => 'sqs',
     'key'    => 'XXXXXX',
      'secret' => 'XXXXXX',
      'queue'  => 'https://sqs.us-west-2.amazonaws.com/XXXXXX/myqueue',
      'region' => 'us-west-2',
   ),

and have also override the queue value in app/config/local/queue.php

并且还覆盖了app/config/local/queue.php 中的队列值

$queue = include __DIR__ . "/../queue.php";
$queue['connections']['sqs']['queue'] = 'https://sqs.us-west-2.amazonaws.com/XXXXXXX/mylocalqueue';
return $queue;

Also I have changed updated the bootstrap/start.phpto set the environment as local

此外,我已更改更新bootstrap/start.php以将环境设置为本地

<?php
$env = $app->detectEnvironment(array(
'local' => array('my-machine-name'),
));

I have pushed the jobs in queue in the controller function as following

我已将控制器功能中队列中的作业推送如下

public function pus_aws($data){
    $queue = $this->app['queue'];
    $queue->push('\ControllerName@ActionName', array(
        'data' => $data,
    ));

    return true;
}

But it is not working. Can anybody please help me to push and run the queued jobs?

但它不起作用。有人可以帮我推送和运行排队的作业吗?

回答by Slue

Are you listening on the queue?

你在听队列吗?

php artisan queue:listen --env=your_environment

http://laravel.com/docs/queues#running-the-queue-listener

http://laravel.com/docs/queues#running-the-queue-listener

For Production-Setup, you should use supervisor as stated in the Laravel Docs.

对于生产设置,您应该使用 Laravel 文档中所述的主管。

See this for a tutorial (uses beanstalkd, but is the same for sqs, only that you do not have to install beanstalkd) http://fideloper.com/ubuntu-beanstalkd-and-laravel4

请参阅此教程(使用 beanstalkd,但与 sqs 相同,只是您不必安装 beanstalkd) http://fideloper.com/ubuntu-beanstalkd-and-laravel4