I have RabbitMQ 3.7 running and it is registered on Consul as rabbitmq-37 and now I want to do upgrade to version 3.8 so I set another cluster as rabbitmq-38. Is it possible to create an alias for a service, like rabbitmq, that will point to one of two services, so that I can always use the same service name in my applications?
I did have some limited success with registration of “external” service like this:
The easiest way to achieve this without changing how you currently register services would be to create a prepared query which serves as an alias to the correct service.
$ curl \
--request POST \
--data @payload.json \
$CONSUL_HTTP_ADDR/v1/query
Clients can then query the address rabbitmq.query.consul, and the address(es) of the rabbitmq-37 service will be returned. This works for all supported query types (A/AAAA, SRV, TXT).