IronMq + Laravel4:如何使它工作

Fra*_*ssi 2 queue iron laravel laravel-4

我有一个问题,我的队列是由IronMQ收到但没有关闭.就像我在这个问题中提出的那样:https: //stackoverflow.com/questions/19200285/laravel4-ironmq-queue-are-not-executed

但是我在Iron仪表板中看到,在我订阅了一个新域之后,它没有被添加到任何列表中.可能IronMQ应该显示一个域名列表,不是吗?这可能是我的队列没有被解雇的原因.我该如何解决这个问题?谢谢!

Ant*_*iro 9

我不确定你是否已经完成了排队等待所需的所有步骤,所以我们来看看它们:

在app/config/queue.php文件中将队列配置为默认为Iron,设置:

'default' => 'iron',
Run Code Online (Sandbox Code Playgroud)

并配置您的连接:

'iron' => array(
    'driver'  => 'iron',
    'project' => 'YOUR PROJECT NUMBER',
    'token'   => 'YOUR TOKEN',
    'queue'   => 'YOUR QEUE NAME',
),
Run Code Online (Sandbox Code Playgroud)

为队列/接收端点创建路由并从Queue :: marshal方法返回响应:

Route::post('queue', function()
{

    Log::info('marshal!');

    return Queue::marshal();

});
Run Code Online (Sandbox Code Playgroud)

并测试它!你的服务器外面使用curl或类似的东西来访问它:

curl --data "param1=whatever" http://<your.domain.com>/queue
Run Code Online (Sandbox Code Playgroud)

编辑:您可以复制整行,只需重新填充您的网址即可.

在文件夹中打开您的日志文件:

app/storage/logs/
Run Code Online (Sandbox Code Playgroud)

你应该在那里看到类似的东西:

[2013-10-10 10:26:09] log.INFO: marshal! [] []
Run Code Online (Sandbox Code Playgroud)

它是由Log::info('marshal!');我们添加到您的元帅路由器生成的.但是你也可能会看到一个错误,上面写着"数据无效.",igore它,我们没有进行真正的测试,我们只需要知道你的编组路线是否正常工作.

现在,您可以在IronMQ上为特定队列注册您的URL:

php artisan queue:subscribe <queue name on IronMQ> <url>
Run Code Online (Sandbox Code Playgroud)

一个例子是:

php artisan queue:subscribe johnnyfittizio http://<your.domain.com>/queue
Run Code Online (Sandbox Code Playgroud)

这与您之前在测试中使用的URL相同.

这个命令必须告诉你:

Queue subscriber added: http://<your.domain.com>/queue
Run Code Online (Sandbox Code Playgroud)

如果没有,你必须再次检查你的配置,你可能在那里做错了.

然后,您可以转到IronMQ的队列页面,检查您的队列是否已订阅:

1. Go to https://hud.iron.io/dashboard

2. On your projects, click in tue MQ button of your project

3. Select the "Queues" tab

4. Click on your queue name, this must be the same you subscribed to using the command "artisan queue:subscribe"

5.In the "PUSH INFORMATION" box, check if your queue push type is set to "multicast".

6.Check if your queue is subscribed in the "SUBSCRIBERS" box, it's in the page bottom right area.
Run Code Online (Sandbox Code Playgroud)

如果一切都已设置,请再次发送电子邮件(通过队列)并检查日志以查看"log.INFO:marshal!" 出现在那里.这次它必须显示但被IronMQ调用.

如果确实如此,并且您没有收到电子邮件,则队列正在运行,您必须检查电子邮件配置.