Sha256: 77ad36499edcd4cb62aa3cd9a8dfd20f7cd213af1a1785b6168cab9794067e44
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'cotton_tail' 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. handle 'say.hello' do puts 'Hello world!' end handle 'say.goodbye' do puts 'Goodbye cruel world!' end 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 payload: payload end end queue 'require_ack_queue', exclusive: true, manual_ack: true do handle 'get.acked' do |_env, _routing_key, delivery_info, _properties, _message| delivery_tag = delivery_info[:delivery_tag] puts "acking with #{delivery_tag}" ch = delivery_info[:channel] ch.ack(delivery_tag) end handle 'get.nacked' do |_env, _routing_key, delivery_info, _properties, _message| delivery_tag = delivery_info[:delivery_tag] puts "nacking with #{delivery_tag}" ch = delivery_info[:channel] ch.nack(delivery_tag) end end end app.start
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cotton-tail-0.3.0 | examples/app.rb |