简体   繁体   English

使用侦听器Laravel 5.2处理AWS SQS队列

[英]Process AWS SQS Queue using Listener Laravel 5.2

I am New to AWS SQS and Laravel. 我是AWS SQS和Laravel的新手。 By following the Laravel 5.2 documentation I have dispatched $customer_id(integer) to AWS SQS. 通过遵循Laravel 5.2文档,我已将$ customer_id(integer)调度到了AWS SQS。

Controller Code: 控制器代码:

$this->dispatch(new ExampleJob($customer_id));

ExampleJob Code: [app\\jobs ExampleJob代码:[app \\ jobs

public function handle(Mailer $mailer)
{
     $mailer->send('Customer.Queue', ['Customer' => $this->customer],  function ($m) {

//            });

Whenever I POST data through controller, new message($customer_id) gets inserted in SQS Queue.That's good. 每当我通过控制器发布数据时,新消息($ customer_id)都会插入到SQS队列中。

Now My problem is I am stuck in processing the messages in SQS queue. 现在我的问题是我被困在处理SQS队列中的消息。 I need to process each customer ID and insert record to another Application(like NetSuite). 我需要处理每个客户ID并将记录插入到另一个Application(例如NetSuite)中。 How to process SQS queue running Queue Listener? 如何处理运行队列侦听器的SQS队列? Please Help me and correct me if I am wrong. 如果我错了,请帮助我并纠正我。

you need then to run the queue listener, as explained in: 然后,您需要运行队列侦听器,如下所述:

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

php artisan queue:listen

See that this listener will be dispatching all the jobs... 看到此侦听器将分派所有作业...

I developed this listener in a JAR to make it simpler, because once that you have a huge amount of jobs, the normal listener it is not efficiently at all, and it consumes a lot of resources. 我用JAR开发了该侦听器以使其更简单,因为一旦您拥有大量的工作,普通的侦听器就根本无法有效工作,并且会消耗大量资源。

https://github.com/smaugho/TunedQueue https://github.com/smaugho/TunedQueue

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM