My journey into asynchronicity proceeds nicely... But now, it seems I
hit a major roadblock:
I have trouble integrating the blocking job = queue.reserve command in
an EventMachine based program.
Any pointers which docu I should read or how this can be solved most
elegantly are appreciated. I got to this point (with beanstalk-
client):
require 'rubygems'
require 'blather/client'
require 'beanstalk-client'
#EM.run do
DEFAULT_PORT = 11300
SERVER_IP = '127.0.0.1'
DEFAULT_PRIORITY = 1
TTR = 3
def get_queue(queue_name)
qonnection = Beanstalk::Pool.new(["#{SERVER_IP}:#{DEFAULT_PORT}"])
qonnection.watch(queue_name)
qonnection.use(queue_name)
qonnection.ignore('default')
puts 'Got connection to beanstalk queue: ' + queue_name.to_s
qonnection
end
outQ = get_queue(:outQ)
setup '[email protected]', 'bwoiurw987933'
handle :ready do
#EM.spawn do
job = outQ.reserve
puts job.id
say job.ybody[:handle], job.ybody[:body]
puts 'say'
job.delete
#end
end
#end
1.) It always just puts out one message and then blocks
2.) Integrating a simple loop do/end doesn't work because then I seem
to block some EventMachine stuff, at least the XMPP lib doesn't work
then
So, any ideas how to get this 'reserving, sending, deleting' to
iterate?
Thanks, Tom
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"beanstalk-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/beanstalk-talk?hl=en
-~----------~----~----~----~------~----~------~--~---