Class: Messaging::Adapters::Postgres::Consumer
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Messaging::Adapters::Postgres::Consumer
show all
- Includes:
- Routing
- Defined in:
- lib/messaging/adapters/postgres/consumer.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Routing
#clear_routes!, #handle, included, #on
Class Method Details
.latest_known_transaction_id ⇒ Object
9
10
11
|
# File 'lib/messaging/adapters/postgres/consumer.rb', line 9
def self.latest_known_transaction_id
connection.select_value('select pg_snapshot_xmin(pg_current_snapshot())')
end
|
Instance Method Details
#shutdown ⇒ Object
29
30
31
32
|
# File 'lib/messaging/adapters/postgres/consumer.rb', line 29
def shutdown
Messaging.logger.info "[#{name}] Consumer stopped"
release_lock
end
|
#start ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/messaging/adapters/postgres/consumer.rb', line 13
def start
obtain_lock
refresh_latest_processed_transaction_id
Messaging.logger.info "[#{name}] Consumer started"
@running = true
process_messages
ensure
shutdown
end
|
#stop ⇒ Object
24
25
26
27
|
# File 'lib/messaging/adapters/postgres/consumer.rb', line 24
def stop
@running = false
Messaging.logger.info "[#{name}] Consumer stopping"
end
|