简体   繁体   中英

Return value queue in Laravel 5.2

Can queue in Laravel 5.2 have a return value? I need all data that processed in the queue has a return value. Is it possible?

Example that I needed : If the user request has been processed, so the results (form the database) will be returned to the user.

在此处输入图片说明

I read the documentation in ( https://laravel.com/docs/5.2/queues ) but the example described here is an asynchronous model (without return value).

Please advise.. Thank you.

Queues are for asynchornous calls. If you need to use queues, you should do something to get the return value, using dispatch, e-mails, etc.

If you need the response in your front-end, I think the best way is to use REDIS + socket.io. After process your queue, you send the message to REDIS and listen with socket.io (google for or try this guide: https://laracasts.com/discuss/channels/general-discussion/step-by-step-guide-to-installing-socketio-and-broadcasting-events-with-laravel-51 ).

If you need in your back-end only, use jobs ( https://laravel.com/docs/5.2/queues#writing-job-classes ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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