Installing RabbitMQ on a local vcap

Assuming you have already done the https://github.com/cloudfoundry/vcap song and dance. I always have a terriable time trying to get items to work on cloudfoundry.com 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 api.vcap.me
vmc login –email blahblah@blahblah.com –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 https://github.com/rabbitmq/rabbitmq-cloudfoundry-samples.git
cd ~/rabbitmq-cloudfoundry-samples/spring && mvn package && cd target && vmc push

You can follow http://support.cloudfoundry.com/entries/20322602-getting-started-with-the-rabbitmq-service-from-a-spring-application 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
~/cloudfoundry/vcap/cloud_controller/log/development.log
/var/log/rabbitmq/*

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
http://support.cloudfoundry.com/entries/20346977-rabbitmq-cloud-foundry-cloud-messaging-that-just-works
https://github.com/rabbitmq/rabbitmq-cloudfoundry-samples
http://support.cloudfoundry.com/entries/20322602-getting-started-with-the-rabbitmq-service-from-a-spring-application
https://github.com/cloudfoundry/vcap
http://support.cloudfoundry.com/entries/20012337-getting-started-guide-command-line-vmc-users
https://raw.github.com/cloudfoundry/vcap/master/setup/install
http://support.cloudfoundry.com/entries/20052116-rabbit-on-local-instance-of-vcap
http://www.rabbitmq.com/admin-guide.html
http://www.rabbitmq.com/man/rabbitmqctl.1.man.html

Follow

Get every new post delivered to your Inbox.