lib/good_job/notifier.rb in good_job-1.9.0 vs lib/good_job/notifier.rb in good_job-1.9.1

- old
+ new

@@ -34,11 +34,11 @@ cattr_reader :instances, default: [], instance_reader: false # Send a message via Postgres NOTIFY # @param message [#to_json] def self.notify(message) - connection = ActiveRecord::Base.connection + connection = Job.connection connection.exec_query <<~SQL.squish NOTIFY #{CHANNEL}, #{connection.quote(message.to_json)} SQL end @@ -157,11 +157,11 @@ future.add_observer(self, :listen_observer) future.execute end def with_listen_connection - ar_conn = ActiveRecord::Base.connection_pool.checkout.tap do |conn| - ActiveRecord::Base.connection_pool.remove(conn) + ar_conn = Job.connection_pool.checkout.tap do |conn| + Job.connection_pool.remove(conn) end pg_conn = ar_conn.raw_connection raise AdapterCannotListenError unless pg_conn.respond_to? :wait_for_notify pg_conn.async_exec("SET application_name = #{pg_conn.escape_identifier(self.class.name)}").clear