Setup Federated Exchange from Custom Virtual Host to Default Virtual Host

458 views
Skip to first unread message

thomas....@gmail.com

unread,
Oct 16, 2014, 7:05:14 AM10/16/14
to rabbitm...@googlegroups.com
Hi,

I'm very much a newbie to RabbitMQ, so any help people can provide would be much appreciated.

I'm trying to setup a federated exchange where the upstream exchange is in a custom virtual host and the downstream is in the default host (/).  I have managed to successfully federate exchanges doing the opposite (from default to custom) but it doesn't seem to work going the other way.

The federation upstream I have configured is in the custom virtual host with a URI syntax of: amqp://username:password@servername

Do I need to change this to explicitly specify the default host?  It works for exchanges within the same virtual hosts (both default and custom) and from default to custom but not from custom to default.

In addition, I've tried setting up this federated exchange in the config file but RabbitMQ doesn't seem to doing anything with it when I restart the service.  I know the config file is hooked in correctly as I can break the service with it.  Do I need to do anything to get this to hook up correctly?

Thanks,
Tom.

Config:
[
  {rabbit,
      [{log_levels, [{federation, info}]}]
    },
  {rabbitmq_federation,
   [{exchanges, [[{exchange,     "testexchange"},
                  {virtual_host, "testvhost"},
                  {type,         "topic"},
                  {durable,      true},
                  {auto_delete,  false},
                  {internal,     false},
                  {upstream_set, "testexchange.upstream"}]]},
    {upstream_sets, [{"testexchange.upstream", [[{connection, "testconnection"}]]}
                    ]},
    {connections, [{"testconnection",   [{host, "testserver"}, 
{protocol, "amqps"},
{virtual_host,    "/"},
                                {username, "User"}, 
{password, "Pass"}]}
                  ]}
   ]}
].


Windows Server 2012 R2
RabbitMQ v3.3.4
Erlang vR16B03-1


Simon MacMullen

unread,
Oct 16, 2014, 9:21:12 AM10/16/14
to thomas....@gmail.com, rabbitm...@googlegroups.com
On 16/10/14 12:05, thomas....@gmail.com wrote:
> Hi,

Hi.

> I'm very much a newbie to RabbitMQ, so any help people can provide would
> be much appreciated.
>
> I'm trying to setup a federated exchange where the upstream exchange is
> in a custom virtual host and the downstream is in the default host (/).
> I have managed to successfully federate exchanges doing the opposite
> (from default to custom) but it doesn't seem to work going the other way.
>
> The federation upstream I have configured is in the custom virtual host
> with a URI syntax of: amqp://username:password@servername
>
> Do I need to change this to explicitly specify the default host?

Yes. The URL above doesn't specify a vhost at all, which federation
interprets as meaning "use the same vhost name as you are currently in".

So to specify the default virtual host from a different one you'd want
amqp://username:password@servername/%2f

(The %2f being the URL encoded name of the vhost). It is a real pity
that "/" is the name of the default virtual host in AMQP, and the path
separator in URLs...

> It
> works for exchanges within the same virtual hosts (both default and
> custom) and from default to custom but not from custom to default.
>
> In addition, I've tried setting up this federated exchange in the config
> file but RabbitMQ doesn't seem to doing anything with it when I restart
> the service. I know the config file is hooked in correctly as I can
> break the service with it. Do I need to do anything to get this to hook
> up correctly?

Are you using RabbitMQ 2.x? The federation config changed completely in
3.0.0, from using the configuration file as below, to using policies /
parameters.

Cheers, Simon
> --
> You received this message because you are subscribed to the Google
> Groups "rabbitmq-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to rabbitmq-user...@googlegroups.com
> <mailto:rabbitmq-user...@googlegroups.com>.
> To post to this group, send email to rabbitm...@googlegroups.com
> <mailto:rabbitm...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

thomas....@gmail.com

unread,
Oct 16, 2014, 9:32:15 AM10/16/14
to rabbitm...@googlegroups.com, thomas....@gmail.com
Hi Simon,

That worked first time.  Thanks for the prompt feedback.

Regarding the config setup, I'm assuming this is no longer with Rabbit MQ v3+?  Is there a way to declare these somewhere without having to do it manually through the management plugin?  As it's quite a manual process, it would be great if we could store this separately in case we need to recover quickly.

Thanks again,
Tom.

Simon MacMullen

unread,
Oct 16, 2014, 9:35:26 AM10/16/14
to thomas....@gmail.com, rabbitm...@googlegroups.com
On 16/10/14 14:32, thomas....@gmail.com wrote:
> Regarding the config setup, I'm assuming this is no longer with Rabbit
> MQ v3+? Is there a way to declare these somewhere without having to do
> it manually through the management plugin?

You can use rabbitmqadmin to script setup via the management plugin.

You can use rabbitmqctl to script setup on the server.

You can use the export/import definitions thing in management, either by
exporting from an already configured server or by generating the JSON
yourself, and upload via a web browser or rabbitmqadmin, or having
management load definitions at startup
(http://www.rabbitmq.com/management.html#load-definitions)

Cheers, Simon

thomas....@gmail.com

unread,
Oct 16, 2014, 9:37:26 AM10/16/14
to rabbitm...@googlegroups.com, thomas....@gmail.com
Fantastic. Thanks again, Simon.

Regards,
Tom.
Reply all
Reply to author
Forward
0 new messages