[rabbitmq-discuss] Amqp Gem and Unicorn
Milo Burr
burrmilo at gmail.com
Mon Dec 24 05:36:32 GMT 2012
Hey all,
I've scoured the internet and this mailing list for Unicorn + Amqp examples
and can't seem to find anything that works for my use case, which is
presumably a very common one. Basically, based on user web requests I want
to publish messages to a queue, have them processed on another server, and
then show the results to the user. I would be extremely grateful is
someone could provide any insight here.
So my current design (based mostly on the Amqp gem examples and this gist:
https://gist.github.com/2692861) waits for a unicorn worker to fork, runs
the EM in another thread, and then does a next_tick that creates the
connection to the server. Two issues:
1. From my controllers, what is the best way to publish messages? That
gist has the controllers calling "EventLoopHelper.run" and then publishing,
but shouldn't the EM already be running in another thread? It seems like I
should be calling next_tick with a block that publishes a message, that way
on the next reactor tick the message will get published. But when I use
next_tick, the messages get publishes sometimes and other times nothing
happens. That is, someones the message isn't published and other times a
bunch of messages are published. Is this a thread safety issue or am I
just completely missing something? I haven't event attempted to add
subscribe functionality into the reactor yet, so nothing should be blocking
the reactor.
2. I also want my unicorn rails app to subscribe to a queue that has the
result of the long-running jobs that occur on another server. If I call
subscribe in the reactor event loop, will that block the reactor from
publishing messages submitted by the controllers?
Any help would be much appreciated!
-Milo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121223/17e5e2a9/attachment.htm>
More information about the rabbitmq-discuss
mailing list