Sha256: 8480ca676322f5614c37cef52f2ccbd0fc5dbc3ec724af47d1d17046c38c7e40

Contents?: true

Size: 710 Bytes

Versions: 1

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

require "sneakers"

require "rabbit"
require "rabbit/receiving/receive"

class Rabbit::Receiving::Worker
  include Sneakers::Worker

  def work_with_params(message, delivery_info, arguments)
    receive_message(message, delivery_info, arguments)
    ack!
  rescue => error
    handle_error!(error)
  end

  def receive_message(message, delivery_info, arguments)
    Rabbit::Receiving::Receive.new(
      message: message.dup.force_encoding("UTF-8"),
      delivery_info: delivery_info,
      arguments: arguments,
    ).call
  end

  def handle_error!(error)
    raise if Rabbit.config.environment == :test
    Rabbit.config.exception_notifier.call(error)
    requeue!
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rabbit_messaging-0.8.1 lib/rabbit/receiving/worker.rb