Php 如何使用Laravel队列系统处理从第三方脚本发布的Laravel中接收到的队列消息?
我有一个单独的脚本,它在SQS队列中发送一些名为Php 如何使用Laravel队列系统处理从第三方脚本发布的Laravel中接收到的队列消息?,php,laravel,queue,laravel-5.7,Php,Laravel,Queue,Laravel 5.7,我有一个单独的脚本,它在SQS队列中发送一些名为drivers.php的消息: include ./vendor/autoload.php use Aws\Sqs\SqsClient; $client = new SqsClient([ 'profile' => 'default', 'region' => 'eu-west-1', 'version' => '2012-11-05' ]); $params = [ 'DelaySeconds'
drivers.php的消息:
include ./vendor/autoload.php
use Aws\Sqs\SqsClient;
$client = new SqsClient([
'profile' => 'default',
'region' => 'eu-west-1',
'version' => '2012-11-05'
]);
$params = [
'DelaySeconds' => 10,
'MessageAttributes' => [
'Driver' => [
'mamae' => 'Keitchi',
'myoji' => 'Tsuchiya',
'skills' => ['drifting', 'touge', 'tyre burning']
]
],
'MessageBody' => "List of drivers",
'QueueUrl' => 'QUEUE_URL'
];
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each back-end using the same
| syntax for every one. Here you may define a default connection.
|
*/
'default' => env('QUEUE_CONNECTION', 'sqs'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'connections' => [
'sqs' => [
'driver' => 'sqs',
'key' => env('SQS_KEY', 'your-public-key'),
'secret' => env('SQS_SECRET', 'your-secret-key'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'your-queue-name'),
'region' => env('SQS_REGION', 'us-east-1'),
],
],
/*
|--------------------------------------------------------------------------
| 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' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];
在laravel上,我在/config/queue.php
上配置了SQS队列:
include ./vendor/autoload.php
use Aws\Sqs\SqsClient;
$client = new SqsClient([
'profile' => 'default',
'region' => 'eu-west-1',
'version' => '2012-11-05'
]);
$params = [
'DelaySeconds' => 10,
'MessageAttributes' => [
'Driver' => [
'mamae' => 'Keitchi',
'myoji' => 'Tsuchiya',
'skills' => ['drifting', 'touge', 'tyre burning']
]
],
'MessageBody' => "List of drivers",
'QueueUrl' => 'QUEUE_URL'
];
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each back-end using the same
| syntax for every one. Here you may define a default connection.
|
*/
'default' => env('QUEUE_CONNECTION', 'sqs'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'connections' => [
'sqs' => [
'driver' => 'sqs',
'key' => env('SQS_KEY', 'your-public-key'),
'secret' => env('SQS_SECRET', 'your-secret-key'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'your-queue-name'),
'region' => env('SQS_REGION', 'us-east-1'),
],
],
/*
|--------------------------------------------------------------------------
| 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' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];
但laravel的文档有自己处理队列的方法:
所以我的问题是如何从第三方脚本中分派laravel作业,以便laravel能够使用自己的机制处理队列中传入的消息