0

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.

enter image description here

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.

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

1 Comment

I have many user (in multiple device) and I need the return values (responses) returned to each user requesting. For example in same time user "A" and user "B" request to server and handled by queues. First, user "A" processed by the queue and get response "A1" and this response must be returned in user "A". Next, user "B" get responses "B1" and this response must be returned in user "B". Could it possible made with Redis + socket.io?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.