examples/app.rb in cotton-tail-0.2.1 vs examples/app.rb in cotton-tail-0.3.0
- old
+ new
@@ -2,11 +2,13 @@
# frozen_string_literal: true
require 'bundler/setup'
require 'cotton_tail'
-app = CottonTail::App.new.define do
+app = CottonTail::App.new
+
+app.routes.draw do
# Create the queue 'hello_world_queue' if it does not exists
queue 'hello_world_queue', exclusive: true do
# Create a binding from the default topic exchange ('amq.topic') to
# the queue 'hello_world_queue'. When a message is received with the
# routing key 'say.hello' the block is executed.
@@ -16,29 +18,33 @@
handle 'say.goodbye' do
puts 'Goodbye cruel world!'
end
- handle 'inspect.message' do |delivery_info, properties, message|
+ handle 'inspect.message' do |env, routing_key, delivery_info, properties, payload|
+ puts env: env
+ puts routing_key: routing_key
puts delivery_info: delivery_info
puts properties: properties
- puts message: message
+ puts payload: payload
end
end
queue 'require_ack_queue', exclusive: true, manual_ack: true do
- handle 'get.acked' do |delivery_info, _props, _msg, opts|
- conn = opts[:conn]
+ handle 'get.acked' do |_env, _routing_key, delivery_info, _properties, _message|
delivery_tag = delivery_info[:delivery_tag]
puts "acking with #{delivery_tag}"
- conn.ack(delivery_tag)
+
+ ch = delivery_info[:channel]
+ ch.ack(delivery_tag)
end
- handle 'get.nacked' do |delivery_info, _props, _msg, opts|
- conn = opts[:conn]
+ handle 'get.nacked' do |_env, _routing_key, delivery_info, _properties, _message|
delivery_tag = delivery_info[:delivery_tag]
puts "nacking with #{delivery_tag}"
- conn.nack(delivery_tag)
+
+ ch = delivery_info[:channel]
+ ch.nack(delivery_tag)
end
end
end
app.start