puppetlabs-rabbitmq: multiple routing keys for same binding

asked 2016-08-02 11:33:41 -0500

will47 gravatar image

updated 2016-08-04 01:39:52 -0500

How can I create 2 bindings between the same exchange / queue, but with multiple routing keys? This is legal and works when setup manually.

I am using create_resources after pulling the bindings from hiera:

create_resources(rabbitmq_binding,  $bindings,  $binding_defaults)

where the source looks like:

    role::rabbitmq::bindings:
    [...]
          'foo.bar.exchange@foo.bar.xyz.queue@/':
            routing_key: 'foo.bar.xyz.key'
          'foo.bar.exchange@foo.bar.xyz.queue@/ ':
            routing_key: 'foo.bar.xyz.published.key'

There's no error, but since there's a duplicate hash key, only one prevails. Just to make sure it wasn't a problem with my use of create_resources, I also tested

rabbitmq_binding { 'foo.bar.exchange@foo.bar.xyz.queue@/':
    user        => $admin_user,
    password    => $admin_pass,
    destination_type => 'queue',
    routing_key => 'foo.bar.xyz.key',
    arguments        => {}, 
    ensure           => present,
  }

rabbitmq_binding { 'foo.bar.exchange@foo.bar.xyz.queue@/':
    user        => $admin_user,
    password    => $admin_pass,
    destination_type => 'queue',
    routing_key => 'foo.bar.xyz.published.key',
    arguments        => {}, 
    ensure           => present,
  }

and of course there's a duplicate resource error that way.

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Rabbitmq_binding[foo.bar.exchange@foo.bar.xyz.queue@/] is already declared; cannot redeclare at /etc/puppet/modules/role/manifests/rabbitmq.pp:XXX on node foo.example.net

I tried making routing_key an array, as well as a comma-delimited string, and even space-padding the hash key (this latter I think might work if I edit the validation rules in the module), and none of that seems to work. It also doesn't seem that there's a way to set the name separately from the resource name, but let me know if I'm wrong there and there's an undocumented way to do this.

Some discussion in https://tickets.puppetlabs.com/browse... and a fix in progress at https://github.com/puppetlabs/puppetl... I changed it so that it will (in a backwards compatible way) accept an array of routing_key values, however, this approach has some limitations.

Would appreciate some more eyes and / or help if anyone else is interested in this. Long term, I think making one resource for each binding is better, but seems like this might have to break backwards compatibility, and would create some big hassles.

edit retag flag offensive close merge delete

Comments

were you able to overcome this? How do you declare multiple routing keys for same binding?

pessoa gravatar imagepessoa ( 2017-08-14 16:27:38 -0500 )edit