Prevent to requeue main task (run same main task in parallel).

If worker have problem with AMQP connection it can sometimes
do not get acknowledgements for message(main task) instantly
and if worker disconect at this time, message will be requeued
and we get several working tasks running in parallel.

Change-Id: If038079e263feb811d019d08944ff1dacd11f30a
Closes-Bug: #1340704
This commit is contained in:
Vladimir Sharshov 2014-07-14 12:52:58 +04:00
parent d68cc54229
commit 18a6861ecf
1 changed files with 1 additions and 2 deletions

View File

@ -47,7 +47,7 @@ module Astute
end
def main_worker
@consumer = AMQP::Consumer.new(@channel, @queue)
@consumer = AMQP::Consumer.new(@channel, @queue, consumer_tag=nil, exclusive=false, no_ack=true)
@consumer.on_delivery do |metadata, payload|
if @main_work_thread.nil? || !@main_work_thread.alive?
Astute.logger.debug "Process message from worker queue: #{payload.inspect}"
@ -70,7 +70,6 @@ module Astute
def perform_main_job(metadata, payload)
@main_work_thread = Thread.new do
metadata.ack
data = parse_data(payload)
@tasks_queue = Astute::Server::TaskQueue.new