Sunday, 13 May 2012

Thoughts on Grails and RabbitMQ on Ubunbu

So I'm building the email notification portion of my app, and I decided to decouple the system by using the AMPQ protocol. I specifically chose RabbitMQ because I have heard good things about it, and cloud foundry (which is hosting my app) also has good support for it.

The problem:
I proceeded to go on the rabbitMQ site to find the latest version of the software. They have the download as a .deb package which I installed. The install took 45 minutes, and right there and then I should've known that something was wrong. Anyways I didn't think too much of it at that point.

Fast forward to yesterday, when I was hooking in the Grails RabbitMQ plugin with my code. From what it seems it was dead simple to send a message:

           if (isSaved) { 
                rabbitSend 'newsubscriber', '', subscriber.id 
                render new StatusResponse(status : 'success') as JSON 
           } 


Here we are calling rabbitSend (provided by the plugin), which makes an sync call to put a message in the 'newsubscriber' topic (which I configured to be a fanout topic). Seems dead simply right? Well, there were a couple problems I found.

1.) First, I checked the server logs, and immediately I saw an error with the grails plugin having problems trying to convert the message. I eventually tracked it down, and it seems that the latest version of the plugin (1.0.0-RC1) had an issue where other people experienced. To resolve that I just fetched the 0.3.3 version and used that instead. All was well (on the deployed app). That took a few hours to track down.

2.) The second problem ... I wasn't able to track down until today. For some reason, when I run the app locally, the messages were not being sent. I logged into the web console and posted messages through their console, and everything worked. So I thought and I thought, and came to the conclusion that maybe the versions of the rabbitmq that is running are different. So I went and downloaded the cloud foundry plugin which had an interface to see the deployed apps. Aha, I thought, it was the version difference...cloud foundry is running 2.4.0, and I was running 2.8.2. So I un installed it and proceeded back to the website to fetch the 2.4.0 deb package. I then tried to install package...but it just stood there...and I waited..and waited...and went for lunch...and waited..

Finally, I realized that something could be wrong with fetching those deb packages from their site, so I instead installed using the command line as they have suggested here: http://www.rabbitmq.com/install-debian.html

Install took 30 seconds, and the server was up. I tried to run my test again, and viola this time it worked!


*I'm using Ubunbtu 12.01 and updated the latest version of the package manager recently, so I'm not sure if that had anything to do with it.

No comments:

Post a Comment