pkieltyka (owner)

Forks

Revisions

gist: 227995 Download_button fork
public
Public Clone URL: git://gist.github.com/227995.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'em-jack'
 
EM.run {
q = EMJack::Connection.new #connect to beanstalk
 
q.each_job do |job|
puts "Got job #{job.jobid}"
 
if process(job)
r = q.delete(job)
r.callback { puts "Deleted #{job}" }
end
end
 
def process(job)
# process....... mmmmmm mmmmmmm
 
# if the job is successful, then return true
return true
 
# if the process failed, then return false which won't
# remove the job from the queue and wait for the ttr
# to expire and automatically put it back on the queue.
# we could delete it and manually put it back on the queue
# but this is a nice failsafe in case the server dies during
# processing... especially if the ttr is lower like 10 seconds.
#return false
end
}