RabbitMQ message queueing with CloudAMQP on Bluemix

Share this post:

RabbitMQ is an open source message broker. It receives and delivers messages from and to your applications. A message broker is (unlike databases and key-value store) purpose built to highly effectively and safely deliver information between your applications. Messages can be sent cross languages, platforms and OS—this way of handling messages decouples your processes and creates a highly scalable system.

CloudAMQP is today operating and providing support to the largest fleet of RabbitMQ clusters in the world! The CloudAMQP service is available in the Bluemix catalog.


If you are new to RabbitMQ, we recommend you read the guide RabbitMQ for beginners before continuing.

Step 1. Create a space and an app within that space

Let’s get started with a managed RabbitMQ server hosted in Bluemix!

  • Register an account and log in to Bluemix
  • Create the space for your organization
  • Create an app within the space:
    Create app

Step 2. Create a CloudAMQP service instance

  • Open the dashboard for your app and select “ADD A SERVICE OR API”
  • Find CloudAMQP in the list of services (direct link) and select a plan. We offer seven different plans, both dedicated clusters, individual servers and vhosts on shared clusters. Dedicated plans provides guaranteed isolation between instances, where as shared plans provides great performance but limits number of connections and number of messages sent per month.
    create service

Step 3. Cloud Foundry command line interface

Use the Cloud Foundry command line interface to deploy and modify applications and service instances. See Getting Started with the cf CLI as required.

  • Go to Bluemix dashboard for you app and press the “Start coding” button
  • Follow the guide and download your “starter code”
  • Go to the local app directory (the files you downloaded) for the application directory
  • Connect and log into Bluemix from the command line.
    <code>$ cf api
    $ cf login -u username -o organization -s space

Step 4. Start coding

All AMQP client libraries work with CloudAMQP and there are AMQP client libraries for almost every platform. Sample code, links to recommended libraries and further information about the client libraries can be found in the CloudAMQP documentation.

  • Add the client library to your dependencies file. The library will be downloaded automatically when you deploy your app. CloudAMQP recommended client libraries for different languages can be found here: Ruby, Python, Celery, node.js, PHP, Java, Clojure, Go, Android, .NET, Perl and C. For example, in Ruby, open the Gemfile and add gem ‘bunny’.

    <code>gem 'bunny'</code>
  • Copy code from the the same language-specific link as above. For example, in Ruby:

    <code>require "bunny" # don't forget to put gem "bunny" in your Gemfile

    services = JSON.parse(ENV['VCAP_SERVICES'])
    cloudamqp_conf = services["cloudamqp"].first
    uri = cloudamqp_conf["credentials"]["uri"]

    b = uri

    b.start # start a communication session with the amqp server

    ch = b.create_channel # create a channel

    q = ch.queue("test") # declare a queue

    # declare a default direct exchange, which is bound to all queues
    e ="")

    # publish a message to the exchange, the message will be routed to the queue "test"
    e.publish("Hello, everybody!", key: value)

    # subscribe from the queue
    q.subscribe(block: true) do |delivery_info, properties, payload|
    puts "This is your message: " + payload + "\n\n"
    b.stop # close the connection

  • Set up connection Environment Variable: The connection and credential information for CloudAMQP is available in the Bluemix VCAP_SERVICES environment variable. It’s a nested JSON objected with all service credentials.

Step 5. Push the App to Bluemix

When the code has been added it is time to deploy the App. Deploying the application into bluemix is easy, just run this command from the app directory:

<code>$ cf push --name your_app </code>

Modify your_app to the application name you chose earlier. Once the application has finished deploying, your app will be connecting, publishing and subscribing via CloudAMQP:


You can write to log and tail your log via cf by:

<code>$ cf logs your_app </code>

Useful tools

Once the service is added to space, a link to CloudAMQP Control Panel will appear within Bluemix. Open the Bluemix Dashboard and press Services and “OPEN CLOUDAMQP DASHBOARD” to get to your CloudAMQP instance.


The instance details, such as connection URL, metrics, logs etc can be seen at the details page. You can also go to the RabbitMQ management interface from the detail page.

From the management interface it is possible to view, handle and delete connections, queues, message etc.

management interface

A full product overview, showing different tools and features to simplify the usage of your RabbitMQ instances can be found in the product overview page.

Various monitoring tools are also available. These tools will address performance issues promptly and automatically, before they impact your business. For more details, see CloudAMQP: Monitoring Tools.

More stories
April 23, 2019

Introducing Private Service Endpoints in IBM Cloud Databases

We recently released an update to all IBM Cloud Databases which allows you to enable public and/or private service endpoints for your database deployments. In this post, we’ll walk you through the setup.

Continue reading

April 19, 2019

Reach Out to the IBM Cloud Development Teams on Slack

Get the help you need fast—directly from the IBM Cloud Development Teams and other users on Slack.

Continue reading

April 19, 2019

Introducing IBM Cloud Object Storage Firewall: Further Secure Your Data

IBM Cloud Object Storage (COS) is giving you more control over who can access your data. We have introduced a new capability allowing you to configure your buckets with trusted IP address(es) that will dictate access to the data in COS.

Continue reading