Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sidekiq return value of a delayed method

I use Sidekiq to run a method delayed in controller (meanwhile I use Redis to update a progress bar). This method call a server, retrieve the data, do some manipulation and calculation; then can take a while.

For example, I have this method:

data_and_status = MyModelName.delay.retrieve_data(params[:tags], "preview", current_user, params[:from], params[:to])

This method should return the data manipulated, but doing in this manner data_and_status is an hash (I guess that is the Sidekiq-job-id). The data returned is very large, doing some caching with Redis is unfortunately out of question.

How can I retrieve a return value of a delayed job (method)?

like image 503
damoiser Avatar asked Feb 15 '23 16:02

damoiser


1 Answers

You say that the data returned (from your asynchronous job) is very large, and relaying it via Redis is out of the question. Well, your sidekiq job runs in a different process, possibly even on a different server, so you must find some inter-process way to transfer the data - if not your message queue (Redis), then the database.

For example:

enter image description here

like image 108
Eero Avatar answered Mar 27 '23 04:03

Eero