Installing RabbitMQ on a local vcap

Assuming you have already done the song and dance. I always have a terriable time trying to get items to work on so decided to see how much of RabbitMQ is available in vcap. Here is a hack to getting RabbitMQ running. I could totally have a baked install and thus the reason why I went down this dark path.

Update and install the following decencies
cd ~/cloudfoundry/vcap
git pull
gem install bundler –no-rdock –no-ri
rake bundler:install
gem install amqp –version ’0.7.1′
gem install daemons –version ’1.1.0′
gem install thin –version ’1.2.8′
cd ~
gem update vmc

Edit ~/cloudfoundry/vcap/bin/vcap and add rabbit as a service

Fire up the services by cd ~/cloudfoundry/vcap && bin/vcap start

Set target and login
vmc target
vmc login –email –passwd blahblahblah

BTW, if you forgot your username or password it can be found in ~/cloudfoundry/vcap/cloud_controller/db/cloudcontroller.sqlite3 . Just rip this file apart or add a new hash for the password.
Check to see the runtimes are correctly available

Check out the following sample to package up
git clone
cd ~/rabbitmq-cloudfoundry-samples/spring && mvn package && cd target && vmc push

You can follow to deploy the app correctly.

Before you actually create the service you want to check the logs out… This is the issue I had with a local vcap and rabbit. The user and vhost never get added to rabbitmq, doing this manually will make the service work. Make sure to tail the logs before running the vmc create-service. That way you can pull out the actual username/password/vhost that vcap will try to send to rabbitmqctl.

tail -f ~/cloudfoundry/vcap/cloud_controller/log/development.log
vmc create-service rabbitmq
vmc bind-service rabbitmq-XXXXX rabbit-simple

After creating the service the logs will display the username/password/vhost but when you bind the service to an application the username and password change and you need to add those by hand with rabbitmqctl

The first set of username/password will not be used, after binding you need the current ones. In this case they were
user: uz25LQnFmJTrC
pass: pfah5U5dFiSRo
vhost: vf883c025ec524e55b11b0db4dcce928e

At this point you can add the data by hand, restart rabbitmq (sometimes queues decided to get eaten) and you should be ready to go.
sudo rabbitmqctl add_user uz25LQnFmJTrC pfah5U5dFiSRo
sudo rabbitmqctl add_vhost vf883c025ec524e55b11b0db4dcce928e
sudo rabbitmqctl set_permissions -p vf883c025ec524e55b11b0db4dcce928e uz25LQnFmJTrC “.*” “.*” “.*”
sudo /etc/init.d/rabbitmq-server restart

Some useful logs to keep tailed

Did I need to go to all this trouble, probably not, but it was fun to investigate what vcap is made and how things are done internally. Since all the code looks like its in place, my guess on how to properly enable rabbit service is to find out what should triggers the calls to ~/cloudfoundry/vcap/services/rabbit/lib/rabbit_service/rabbit_node.rb and debug why the calls are actually failing to contact the local rabbitmq service.

Useful links

Creating new java project with Cloudfoundry and Spring Source Tool

After picking up SpringSource Tool Suite and Installing the Cloudfoundry plugins creating a new java project is painless, as long as you know which options to choose. From the New wizard you need to choose “Dynamic Web Project”

Target runtime at the time of this post was “Cloud Foundry (Runtime) v1.0″ and Dynamic web module version “2.5″ with a Configuration of “Default Configuration for Cloud Foundry (Runtime) v1.0″

The Project layout

Creating a new Package and class

Create a classic HelloWorld

Time to extend the HttpServlet and override doGet

Add entries of the servlet and servlet-mapping

Add Application

Start the service

And you have the basic hello world from the cloud foundry samples.


Get every new post delivered to your Inbox.