I’m creating a message queue system, (think JMS message queue)
Basically, I’ll be firing off an http request as soon as a row appears
in a database.
Now in past implementations I’ve done the following.
- Polled the database every 0.10 seconds.
- If something was there to work, I’d tag it as complete.
- Create a separate thread. (no further database hits will made)
- Run my Net::HTTP.get_response(), which takes from 0.00001 to 600
seconds to complete. - Write output to some log file.
What’s gotten me into trouble now, is I want to do touch the database.
Which creates all sorts of havoc in rails when threaded.
I’m pondering using BackgroundDB, but it looks like it’s meant for slow
running tasks, not thousands of messages flying back and forth.
I was also thinking of, not touching the database in the thread, but
posting the results back to a separate instance of the rails app, and
let that instance handle the writes to the database. This seems kludgey
though.
I’ve heard that merb, and some of those are threadsafe, maybe I can have
this piece of it, using that instead?
Or perhaps something else.
Thanks for any response!