mirror of
https://github.com/jimeh/bunnyrun.git
synced 2026-02-19 07:56:40 +00:00
Add some basic examples
This commit is contained in:
18
examples/basic-consumers-example/ping_consumer.rb
Normal file
18
examples/basic-consumers-example/ping_consumer.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'bunnyrun'
|
||||
|
||||
class PingConsumer < BunnyRun::Consumer
|
||||
queue 'ping'
|
||||
|
||||
exchange 'ping-pong', type: :direct
|
||||
bind 'ping-pong', routing_key: 'ping'
|
||||
|
||||
manual_ack true # default is false
|
||||
|
||||
def perform(message)
|
||||
logger.info "#{self.class} received: #{message.payload}"
|
||||
sleep 1
|
||||
|
||||
publish('ping-pong', 'PONG', routing_key: 'pong')
|
||||
message.ack
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user