lib/good_job/notifier.rb in good_job-2.8.1 vs lib/good_job/notifier.rb in good_job-2.9.0

- old
+ new

@@ -14,13 +14,10 @@ include ActiveSupport::Callbacks define_callbacks :listen, :unlisten include Notifier::ProcessRegistration - # Raised if the Database adapter does not implement LISTEN. - AdapterCannotListenError = Class.new(StandardError) - # Default Postgres channel for LISTEN/NOTIFY CHANNEL = 'good_job' # Defaults for instance of Concurrent::ThreadPoolExecutor EXECUTOR_OPTIONS = { name: name, @@ -127,12 +124,10 @@ # Invoked on completion of ThreadPoolExecutor task # @!visibility private # @return [void] def listen_observer(_time, _result, thread_error) - return if thread_error.is_a? AdapterCannotListenError - if thread_error GoodJob._on_thread_error(thread_error) ActiveSupport::Notifications.instrument("notifier_notify_error.good_job", { error: thread_error }) connection_error = CONNECTION_ERRORS.any? do |error_string| @@ -212,9 +207,18 @@ raw_connection = connection.raw_connection if raw_connection.respond_to?(:wait_for_notify) raw_connection.wait_for_notify(WAIT_INTERVAL) do |channel, _pid, payload| yield(channel, payload) end + elsif raw_connection.respond_to?(:jdbc_connection) + raw_connection.execute_query("SELECT 1") + notifications = raw_connection.jdbc_connection.getNotifications + Array(notifications).each do |notification| + channel = notification.getName + payload = notification.getParameter + yield(channel, payload) + end + sleep WAIT_INTERVAL else sleep WAIT_INTERVAL end end end