Getting Started with Predix Message Queue

Creating a Predix Message Queue Service Instance

About This Task

You can use Cloud Foundry commands to view available service plans in the Cloud Foundry marketplace.

Procedure

  1. Use the cf marketplace command to view the available services. For example,
    $ cf marketplace
    Getting services from marketplace in org predix-services / space ref-apps as [email protected]...
    OK
    
    service             plans                                                                        description
    predix-message-queue     Dedicated-1-Q20*, Dedicated-3HA-Q20* 
  2. Use the cf create-service command to create a new instance of predix-message-queue. Specify the desired plan and a name for the new service instance. Example:
    $ cf create-service predix-message-queue Dedicated-1-Q20 my-predix-message-queue
    Creating service instance my-predix-message-queue in org predix-services / space ref-apps as [email protected]...
    OK
    
    Create in progress. Use 'cf services' or 'cf service my-predix-message-queue' to check operation status.
    
    Attention: The plan `Dedicated-1-Q20` of service `predix-message-queue` is not free.  
    The instance `my-predix-message-queue` will incur a cost.  Contact your administrator if you think this is in error.
  3. Once the service instance is created, you should receive a status of create succeeded. You can then bind the service instance to an app with the cf bind-service command. Example:
    cf bind-service my-app my-predix-message-queue

Retrieving Predix Message Queue Environment Variables

About This Task

Cloud Foundry will expose information about the Predix Message Queue service bound to the application in JSON format using an environment variable called VCAP_SERVICES. This should contain everything that you need to know to interact with service instance. You can view the contents of the VCAP_SERVICES variable for a given app using the cf env command. Here's an example:

Procedure

Example of VCAP_SERVICES
{
 "VCAP_SERVICES": {
  "predix-message-queue": [
   {
    "credentials": {
     "dashboard_url": "https://rabbitmq-8b12ecb4-0edc-451b-8c1d-d9c525b42a9d.run.aws-usw02-sb.ice.predix.io/#/login/8b12ecb4-0edc-451b-8c1d-d9c525b42a9d/Dm9eDcpWasaGOtHWESkCXg",
     "hostname": "10.72.74.45",
     "hostnames": [
      "10.72.74.45"
     ],
     "http_api_uri": "https://8b12ecb4-0edc-451b-8c1d-d9c525b42a9d:Dm9eDcpWasaGOtHWESkCXg@rabbitmq-8b12ecb4-0edc-451b-8c1d-d9c525b42a9d.run.aws-usw02-sb.ice.predix.io/api/",
     "http_api_uris": [
      "https://8b12ecb4-0edc-451b-8c1d-d9c525b42a9d:Dm9eDcpWasaGOtHWESkCXg@rabbitmq-8b12ecb4-0edc-451b-8c1d-d9c525b42a9d.run.aws-usw02-sb.ice.predix.io/api/"
     ],
     "password": "Dm9eDcpWasaGOtHWESkCXg",
     "protocols": {
      "amqp": {
       "host": "10.72.74.45",
       "hosts": [
        "10.72.74.45"
       ],
       "password": "Dm9eDcpWasaGOtHWESkCXg",
       "port": 5672,
       "ssl": false,
       "uri": "amqp://8b12ecb4-0edc-451b-8c1d-d9c525b42a9d:[email protected]:5672/8b12ecb4-0edc-451b-8c1d-d9c525b42a9d",
       "uris": [
        "amqp://8b12ecb4-0edc-451b-8c1d-d9c525b42a9d:[email protected]:5672"
       ],
       "username": "8b12ecb4-0edc-451b-8c1d-d9c525b42a9d",
       "vhost": "8b12ecb4-0edc-451b-8c1d-d9c525b42a9d"
      },
      "management": {
       "host": "10.72.74.45",
       "hosts": [
        "10.72.74.45"
       ],
       "password": "Dm9eDcpWasaGOtHWESkCXg",
       "path": "/api/",
       "port": 15672,
       "ssl": false,
       "uri": "http://8b12ecb4-0edc-451b-8c1d-d9c525b42a9d:[email protected]:15672/api/",
       "uris": [
        "http://8b12ecb4-0edc-451b-8c1d-d9c525b42a9d:[email protected]:15672"
       ],
       "username": "8b12ecb4-0edc-451b-8c1d-d9c525b42a9d",
       "vhost": "8b12ecb4-0edc-451b-8c1d-d9c525b42a9d"
      }
     },
     "ssl": false,
     "uri": "amqp://8b12ecb4-0edc-451b-8c1d-d9c525b42a9d:[email protected]/8b12ecb4-0edc-451b-8c1d-d9c525b42a9d",
     "uris": [
      "amqp://8b12ecb4-0edc-451b-8c1d-d9c525b42a9d:[email protected]/8b12ecb4-0edc-451b-8c1d-d9c525b42a9d"
     ],
     "username": "8b12ecb4-0edc-451b-8c1d-d9c525b42a9d",
     "vhost": "8b12ecb4-0edc-451b-8c1d-d9c525b42a9d"
    },
    "label": "predix-message-queue",
    "name": "my-predix-message-queue",
    "plan": "Dedicated-1-Q20",
    "provider": null,
    "syslog_drain_url": null,
    "tags": [
     "rabbitmq"
    ],
    "volume_mounts": []
   }
  ]
 }
}
The predix-message-queue key at the root of the VCAP_SERVICES json should contain a list of all bound Predix Message Queue services for the app. Within that key is all of the information necessary to interact with the service.

VCAP Services Key-Value Pair Definitions

VCAP Key-Value Pairs

This section describes each key in the VCAP_SERVICES JSON for the Predix Message Queue service and its purpose.

VCAP KeyValue Definition
label:The name of the Cloud Foundry service this instance belongs to, in this case predix-message-queue.
name:The name of the service instance.
plan:The service plan for the instance.
provider:Not used for this service.
syslog_drain_url:Syslog URL for logging services. Not used for RabbitMQ.
tags:List of tags about the type of service. Can be used for identifying the type of an attached service.
volume_mounts:Metadata about attached storage volumes. Not used for this service.

Credentials Keys

The credentials key contains the information necessary to connect and authenticate to the Predix Message Queue service.

Credential KeyValue Definition
dashboard_url :The URL to the RabbitMQ web management interface.
hostname :The hostname or IP address of the primary RabbitMQ service node.
hostnames: A list of hostnames or URLs for all of the nodes in the RabbitMQ cluster.
http_api_uri: The URI for the RabbitMQ HTTP API.
http_api_uris:A list of URIs for the HTTP management API.
password: The password for the service's RabbitMQ user account

Protocols Keys

Protocols are specified as a subsection of Credentials key. The protocol keys provide all of the necessary details for connecting to the service with various protocols

Protocol KeyValue Definition
amqp :Credentials (host, username, password, vhost, uri etc) necessary for creating AMQP connections to the service.
management :Credentials for the RabbitMQ management API.