mirror of
https://github.com/ditkrg/rabbit_carrots.git
synced 2026-01-22 22:06:40 +00:00
Adds error classes
This commit is contained in:
parent
1385400566
commit
b9528c66bf
@ -8,5 +8,17 @@ require 'rabbit_carrots/railtie' if defined?(Rails)
|
||||
|
||||
module RabbitCarrots
|
||||
class Error < StandardError; end
|
||||
# Your code goes here...
|
||||
module EventHandlers
|
||||
module Errors
|
||||
class IrrelevantMessage < StandardError
|
||||
end
|
||||
|
||||
class NackMessage < StandardError
|
||||
end
|
||||
|
||||
class NackAndRequeueMessage < StandardError
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -41,10 +41,10 @@ def run_task(queue_name:, handler_class:, routing_keys:)
|
||||
Rails.logger.info "Received from queue: #{queue_name}, Routing Keys: #{routing_keys}"
|
||||
handler_class.handle!(channel, delivery_info, properties, payload)
|
||||
channel.ack(delivery_info.delivery_tag, false)
|
||||
rescue EventHandlers::Errors::NackMessage, JSON::ParserError => _e
|
||||
rescue RabbitCarrots::EventHandlers::Errors::NackMessage, JSON::ParserError => _e
|
||||
Rails.logger.info "Nacked message: #{payload}"
|
||||
channel.nack(delivery_info.delivery_tag, false, false)
|
||||
rescue EventHandlers::Errors::NackAndRequeueMessage => _e
|
||||
rescue RabbitCarrots::EventHandlers::Errors::NackAndRequeueMessage => _e
|
||||
Rails.logger.info "Nacked and Requeued message: #{payload}"
|
||||
channel.nack(delivery_info.delivery_tag, false, true)
|
||||
rescue StandardError => e
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module RabbitCarrots
|
||||
VERSION = "0.1.13"
|
||||
VERSION = "0.1.14"
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user