Logo: Relish

  1. Sign in

Project: Message-driver 0.7

Binding AMQP destinations to exchanges

  • @bunny
  • @read_queues_directly
Background
Given
the following broker configuration
MessageDriver::Broker.define do |b|
  b.destination :direct_exchange, "amq.direct", type: :exchange
end
Scenarios
Binding a queue to an exchange
When
I execute the following code
MessageDriver::Broker.define do |b|
  b.destination :my_queue, "my_bound_queue", exclusive: true, bindings: [
    {source: "amq.direct", args: {routing_key: "test_binding"}},
    {source: "amq.direct", args: {routing_key: "spec_binding"}}
  ]
end

publish(:direct_exchange, "Test Message", {}, {routing_key: "test_binding"})
publish(:direct_exchange, "Spec Message", {}, {routing_key: "spec_binding"})
Then
I expect to find the following 2 messages on :my_queue
body
Test Message
Spec Message
Binding an exchange to an exchange

RabbitMQ's AMQP 0.9 extenstions support binding exchanges to exchanges

When
I execute the following code
MessageDriver::Broker.define do |b|
  b.destination :fanout, "amq.fanout", type: :exchange, bindings: [
    {source: "amq.direct", args: {routing_key: "test_binding"}},
    {source: "amq.direct", args: {routing_key: "spec_binding"}}
  ]
  b.destination :my_queue, "my_bound_queue", exclusive: true, bindings: [{source: "amq.fanout"}]
end

publish(:direct_exchange, "Test Message", {}, {routing_key: "test_binding"})
publish(:direct_exchange, "Spec Message", {}, {routing_key: "spec_binding"})
Then
I expect to find the following 2 messages on :my_queue
body
Test Message
Spec Message

Last published over 3 years ago by soupmatt.