LATEST VERSION: 1.9.0 - CHANGELOG
RabbitMQ for PCF v1.7.23

RabbitMQ® Entries in the VCAP_SERVICES Environment Variable

Applications running in Cloud Foundry gain access to the bound service instances via an environment variable credentials hash called VCAP_SERVICES. An example hash is show below:


{
    "p-rabbitmq": [{
        "label": "p-rabbitmq",
        "name": "my-rabbit-service-instance",
        "plan": "standard",
        "tags": ["rabbitmq", "messaging", "message-queue", "amqp", "pivotal"],
        "credentials": {
            "dashboard_url": "http://pivotal-rabbitmq.your.pcf.example.com/#/login/b5d0ad14-4352-48e8-8982-d5b1d257029f/tavk86pnnns1ddiqpsdtbchurn",
            "username": "b5d0ad14-4352-48e8-8982-d5b1d257029f",
            "vhost": "62e5ab21-7b38-44ac-b139-6aa97af01cd7",
            "password": "tavk86pnnns1ddiqpsdtbchurn",
            "ssl": false,
            "hostname": "10.0.0.41",
            "hostnames": [
                "10.0.0.41",
                "10.0.0.51"],
            "uri": "amqp://b5d0ad14-4352-48e8-8982-d5b1d257029f:tavk86pnnns1ddiqpsdtbchurn@10.0.0.41/62e5ab21-7b38-44ac-b139-6aa97af01cd7",
            "uris": [
                "amqp://b5d0ad14-4352-48e8-8982-d5b1d257029f:tavk86pnnns1ddiqpsdtbchurn@10.0.0.41/62e5ab21-7b38-44ac-b139-6aa97af01cd7",
                "amqp://b5d0ad14-4352-48e8-8982-d5b1d257029f:tavk86pnnns1ddiqpsdtbchurn@10.0.0.51/62e5ab21-7b38-44ac-b139-6aa97af01cd7"],
            "http_api_uri": "http://b5d0ad14-4352-48e8-8982-d5b1d257029f:tavk86pnnns1ddiqpsdtbchurn@10.0.0.41:15672/api",
            "http_api_uris": [
                "http://b5d0ad14-4352-48e8-8982-d5b1d257029f:tavk86pnnns1ddiqpsdtbchurn@10.0.0.41:15672/api",
                "http://b5d0ad14-4352-48e8-8982-d5b1d257029f:tavk86pnnns1ddiqpsdtbchurn@10.0.0.51:15672/api"],
            "protocols": {
                "amqp": {
                    "password": "tavk86pnnns1ddiqpsdtbchurn",
                    "port": 5672,
                    "ssl": false,
                    "username": "b5d0ad14-4352-48e8-8982-d5b1d257029f",
                    "vhost": "62e5ab21-7b38-44ac-b139-6aa97af01cd7",
                    "host": "10.0.0.41",
                    "hosts": [
                        "10.0.0.41",
                        "10.0.0.51"],
                    "uri": "amqp://b5d0ad14-4352-48e8-8982-d5b1d257029f:tavk86pnnns1ddiqpsdtbchurn@10.0.0.41:5672/62e5ab21-7b38-44ac-b139-6aa97af01cd7",
                    "uris": [
                        "amqp://b5d0ad14-4352-48e8-8982-d5b1d257029f:tavk86pnnns1ddiqpsdtbchurn@10.0.0.41:5672/62e5ab21-7b38-44ac-b139-6aa97af01cd7",
                        "amqp://b5d0ad14-4352-48e8-8982-d5b1d257029f:tavk86pnnns1ddiqpsdtbchurn@10.0.0.51:5672/62e5ab21-7b38-44ac-b139-6aa97af01cd7"]},
                "management": {
                    "username": "b5d0ad14-4352-48e8-8982-d5b1d257029f",
                    "password": "tavk86pnnns1ddiqpsdtbchurn",
                    "path": "/api",
                    "port": 15672,
                    "ssl": false,
                    "host": "10.0.0.41",
                    "hosts": [
                        "10.0.0.41",
                        "10.0.0.51"],
                    "uri": "http://b5d0ad14-4352-48e8-8982-d5b1d257029f:tavk86pnnns1ddiqpsdtbchurn@10.0.0.41:15672/api",
                    "uris": [
                        "http://b5d0ad14-4352-48e8-8982-d5b1d257029f:tavk86pnnns1ddiqpsdtbchurn@10.0.0.41:15672/api",
                        "http://b5d0ad14-4352-48e8-8982-d5b1d257029f:tavk86pnnns1ddiqpsdtbchurn@10.0.0.51:15672/api"]}}}}]}

You can search for your service by its name, given when creating the service instance, or dynamically via the tags or label properties. The credentials property can be used as follows:

  • The top level properties uri, uris, vhost, username, password, hostname and hostnames provide access to the AMQP 0.9.1 protocol.

  • A more flexible approach is provided by the credentials.protocols property, which has a key per enabled protocol. The possible keys are amqp, management, mqtt, and stomp. If SSL is enabled, then the keys will be amqp+ssl, management+ssl, mqtt+ssl, and stomp+ssl respectively.

  • The values associated with each of these keys gives access credentials specific to each protocol. In all cases, URIs are provided, along with the individual components.

Connecting to a Highly Available RabbitMQ Cluster

The latest version of RabbitMQ tile 1.5.*, allows for a highly available cluster through multiple HAProxy nodes. The hostnames, uris and hosts properties have been added and should be used in preference over the equivalent singular properties. The singular properties are maintained for backwards compatibility and will always contain the first value from the equivalent plural property. The singular properties will eventually be deprecated.

For example with two HAProxy jobs deployed the following properties will be present:

"hostname": "10.0.0.41",
"hostnames": [
    "10.0.0.41",
    "10.0.0.51"]

Changing Enabled Plugins and Protocols

Note: Removing or adding plugins/protocols may cause apps bound with RabbitMQ to break.

If you adjust the plugins and protocols enabled for RabbitMQ, you may need to force all app’s VCAP_SERVICES environment variable to be regenerated. Adding and removing the following plugins require bound applications to be restaged:

  • rabbitmq_management
  • rabbitmq_stomp
  • rabbitmq_mqtt
  • rabbitmq_amqp1_0

In common with all services in Pivotal Cloud Foundry (PCF), the VCAP_SERVICES environment variable for an application is only modified when the application is bound to a service instance. Users will need to cf unbind-service, cf bind-service and cf restage their app in this scenario.

Create a pull request or raise an issue on the source for this page in GitHub