lib/pwwka/configuration.rb in pwwka-0.12.0 vs lib/pwwka/configuration.rb in pwwka-0.13.0.RC1
- old
+ new
@@ -9,14 +9,23 @@
attr_accessor :delayed_exchange_name
attr_accessor :logger
attr_accessor :options
attr_accessor :async_job_klass
attr_accessor :send_message_resque_backoff_strategy
- attr_accessor :requeue_on_error
+ attr_reader :requeue_on_error
attr_writer :app_id
- attr_writer :keep_alive_on_handler_klass_exceptions
+ attr_writer :error_handling_chain
+ def keep_alive_on_handler_klass_exceptions=(val)
+ @keep_alive_on_handler_klass_exceptions = val
+ @error_handling_chain = nil
+ end
+ def requeue_on_error=(val)
+ @requeue_on_error = val
+ @error_handling_chain = nil
+ end
+
def initialize
@rabbit_mq_host = nil
@topic_exchange_name = "pwwka.topics.#{Pwwka.environment}"
@delayed_exchange_name = "pwwka.delayed.#{Pwwka.environment}"
@logger = MonoLogger.new(STDOUT)
@@ -57,9 +66,24 @@
@payload_logging = new_payload_logging_level
end
def allow_delayed?
options[:allow_delayed]
+ end
+
+ def error_handling_chain
+ @error_handling_chain ||= begin
+ klasses = []
+ if requeue_on_error
+ klasses << Pwwka::ErrorHandlers::NackAndRequeueOnce
+ else
+ klasses << Pwwka::ErrorHandlers::NackAndIgnore
+ end
+ unless Pwwka.configuration.keep_alive_on_handler_klass_exceptions?
+ klasses << Pwwka::ErrorHandlers::Crash
+ end
+ klasses
+ end
end
end
end