[rabbitmq-discuss] Sender-selected distribution appears to not work

Laing, Michael P. Michael.Laing at nytimes.com
Sat Apr 21 13:27:46 BST 2012


I would like to use this feature as documented at http://www.rabbitmq.com/blog/2011/03/ and http://www.rabbitmq.com/extensions.html

I tested both manually using the management console and with a coffeescript program but cannot make it work.

Of course it is possible – even probable – that I have an error in understanding… :)

My application is one where I would like to publish each message using multiple routing keys.

In general each subscriber will bind with one key.

Here is a test that fails both on my mac using RabbitMQ 2.7.1 / Erlang R15B and a linux box using RabbitMQ 2.7.1 / Erlang R14B:

# test.coffee
amqp = require 'amqp'

t1_message = (message, headers, properties) ->
  console.log ""+
    "\nSuccess: t1: message: #{JSON.stringify message}"+
    "\nheaders: #{JSON.stringify headers}"+
    "\nproperties: #{JSON.stringify properties, undefined, 4}"

  process.exit 0

t0_message = (message, headers, properties) ->
  console.log ""+
    "\nBroadcast: t0: message: #{JSON.stringify message}"+
    "\nheaders: #{JSON.stringify headers}"+
    "\nproperties: #{JSON.stringify properties, undefined, 4}"

bailout = ->
  console.log "\nFailure"
  process.exit 1

amqp_connection = amqp.createConnection()

amqp_connection.on 'ready', () ->
  properties = type:'topic', durable: true

  amqp_connection.exchange "test", properties, (exchange) ->
    properties = durable:true, autoDelete:false

    amqp_connection.queue "t1", properties, (queue) ->
      queue.bind exchange, "foo"

      queue.subscribe (message, headers, properties) ->
        t1_message message, headers, properties

      amqp_connection.queue "t0", properties, (queue) ->
        queue.bind exchange, "*"

        queue.subscribe (message, headers, properties) ->
          t0_message message, headers, properties

        cc_header = cc:["foo","bar"]
        properties = contentType:"application/json", headers:cc_header
        message = test:"message content"
        exchange.publish "whatever", message, properties
        setTimeout bailout, 1000

Here's the output – if it had succeeded, both queues would have received the message:

Broadcast: t0: message: {"test":"message content"}
headers: {"cc":{"0":"foo","1":"bar"}}
properties: {
"contentType": "application/json",
"headers": {

        "cc": {
            "0": "foo",
            "1": "bar"
        }
    },
    "queue": "t0",
    "deliveryTag": 1,
    "redelivered": false,
    "exchange": "test",
    "routingKey": "whatever",
    "consumerTag": "node-amqp-38169-0.10587440640665591"
}

Failure
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120421/1668b6d9/attachment.htm>


More information about the rabbitmq-discuss mailing list