如何使用laravel队列系统处理从第三方脚本发布的Laravel中收到的Queue消息?

问题描述

我有一个单独的脚本,用于在SQS队列上发送一些名为drifters.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'
];

在laravel上,我在./config/queue.PHP上配置了SQS队列:

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的文档有其处理队列的方式:https://laravel.com/docs/5.7/queues

所以我的问题是我该如何从第三方脚本中分派laravel作业,以便laravel能够以其自身的机制处理来自队列的传入消息?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)