【发布时间】:2016-05-07 13:44:05
【问题描述】:
我有一个表单,允许用户输入一些文本并上传图像(然后调整图像大小并发送到 TinyPNG.com 进行优化)。 单击提交按钮后,表单通过 JQuery AJAX 发送数据。在数据发布完成后,我想通过 AJAX 函数中的 On Success 向用户显示一些消息,但无需等待图像处理过程。为此,我使用 Iron 创建了一个 Laravel 队列,代码如下:
\Queue::push('RenameClassImage',[$_POST['temp_img_id'], $class_id,$final_path,$_POST['crop_w'],$_POST['crop_h'],$_POST['crop_x'],$_POST['crop_y']]);
总体上一切正常,除了 AJAX 成功功能仅在整个图像处理过程完成后触发(这需要很长时间)。
下面是我的队列配置文件。如果您希望我包含任何其他代码,请告诉我。提前致谢
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Driver
|--------------------------------------------------------------------------
|
| The Laravel queue API supports a variety of back-ends via an unified
| API, giving you convenient access to each back-end using the same
| syntax for each one. Here you may set the default queue driver.
|
| Supported: "null", "sync", "database", "beanstalkd",
| "sqs", "iron", "redis"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'expire' => 60,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'ttr' => 60,
],
'sqs' => [
'driver' => 'sqs',
'key' => 'your-public-key',
'secret' => 'your-secret-key',
'queue' => 'your-queue-url',
'region' => 'us-east-1',
],
'iron' => [
'driver' => env('QUEUE_DRIVER'),
'host' => env('QUEUE_HOST'),
'token' => env('QUEUE_TOKEN'),
'project' => env('QUEUE_PROJECT'),
'queue' => env('QUEUE_NAME'),
'encrypt' => true,
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => 'default',
'expire' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'database' => 'mysql', 'table' => 'failed_jobs',
],
];
【问题讨论】:
-
您可以从您的
.env文件中添加QUEUE_DRIVER的值吗? -
当然,它是 QUEUE_TYPE=iron QUEUE_HOST=mq-aws-us-east-1.iron.io QUEUE_TOKEN= 每个我的 Iron 帐户 QUEUE_PROJECT= 每个我的 Iron 帐户 QUEUE_NAME= 每个我的 Iron 帐户
-
不应该是
QUEUE_TYPE是QUEUE_DRIVER吗?
标签: php jquery ajax laravel queue