Setting Up RabbitMQ as a User-Provided Service

This document guides you through binding your App to a RabbitMQ instance not listed in the Kf marketplace (including RabbitMQ click to deploy on Marketplace with the Spring Cloud Foundry Connector. This results in the RabbitMQ credentials being injected into your App, just like binding to services provisioned through marketplace plans.

Before you begin

  • Ensure you have RabbitMQ installed and accessible by your Kf cluster.
  • Ensure RabbitMQ has already been set up for your App.
  • Ensure you have targeted the Space running your App.

Create the user-provided instance

For Kf to successfully bind an App to your RabbitMQ instance, the minimum environment variable is the URI (for example amqp://username:password@host:port/vhost?query). Additional key-value pairs may be included if desired. The RabbitMQ documentation can help with creating a URI string. The following example should be sufficient for basic deployments.

kf cups service-instance-name -p '{"uri":"amqp://username:password@rabbitmq-host:5672"}' -t "rabbitmq"

Bind your App

Now that the user-provided service has been created, you can bind your App to the instance name:

kf bind-service application-name service-instance-name

Restart your App to for the changes to take effect:

kf restart application-name

You can confirm the new environment variables being provided to your App:

kf vcap-services application-name

Update the user-provided instance

If there are changes to the environment (for example password or host update in the URI, or the addition of new key-value pairs) that need to be passed on to any App bound to it, you can update the user-provided instance.

kf uups service-instance-name -p '{"uri":"new-uri", "some-new-key": "some-new-value"}'
kf unbind-service application-name service-instance-name
kf bind-service application-name service-instance-name

Related documents