Class: AwsSqsMoniter::Middleware::Server::ActiveRecord::Idempotence

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_sqs_moniter/middleware/server/active_record/idempotence.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger: Shoryuken::Logging.logger) ⇒ Idempotence

Returns a new instance of Idempotence.



6
7
8
# File 'lib/aws_sqs_moniter/middleware/server/active_record/idempotence.rb', line 6

def initialize logger: Shoryuken::Logging.logger
  @logger = logger
end

Instance Method Details

#call(_worker, queue, sqs_msg, _body) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/aws_sqs_moniter/middleware/server/active_record/idempotence.rb', line 10

def call _worker, queue, sqs_msg, _body
  message = TypedMessage.new sqs_msg

  if ProcessedMessage.exists? message_id: message.id, queue: queue
    @logger.info middleware: 'idempotence', ignored_message_id: message.id
  else
    yield
    ProcessedMessage.log message
  end
end