I have created ruby thread which keep polling messages from Queue. The following is the basic code block which keeps polling the queue infinitely.How could i initialise this method (poll method in class Poller ) on rails server start up so that this code(infinite loop thread) block runs when the application starts
class Poller
class << self
def poll
begin
----polling logic for queue
sleep(1.minute)
end while(true)
end
end
end
How do i initialise above code in a rails initialisers so that the above code will start polling messages from queue?
You can call poll method from initializers and execute code.
Just create one .rb file in initializers and call poll method.
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.