is it possible in rails 2.3.X to start a new chain of commands after a request has been rendered and returned to the requestor?
I need that feature in order to work with an asynchronous API on the other side: They expect a response to their request and after that response is done my rails app should send a new http-request to them (post something to their API)...
What are the possibilities here? Is there something like a after_render hook? Should I make use of threads or background tasks and how could this be done?
I would be very glad for some solutions :-)
Kind regards
UPDATE: The Return-Code (eg. 200) should be sent to the requestor before the other calls are executed
The easiest thing to do is spawn a new thread. This is assuming that it is a lightweight call and you don't need advanced error logging or retry logic.
Thread.new do
puts "call the api"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With