18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/queued_mail/queue/amazon_sqs.rb', line 18
def task
if ENV['PIDFILE']
File.open(ENV['PIDFILE'], 'w'){ |f| f << Process.pid }
end
begin
queue.poll(poll_interval: 5, batch_size: 1) do |received_message|
begin
Rails.logger.info "receive message_id:#{received_message.id} md5:#{received_message.md5}"
args = JSON.parse(received_message.body)
QueuedMail::Job.perform(args)
rescue => e
received_message.visibility_timeout = 60
raise e
end
end
rescue SignalException
rescue Exception => e
Rails.logger.error e
retry
end
end
|