Im currently exploring Rabbit MQ and had a few issues getting up and running reliably on Mac OSX. The problem wasted so much of my own free time that I thought it would be a good idea to post about it and perhaps it might help others in the future.

The Problem

The broken boots normally as the rabbitmq user defined in the system – however, when trying to connect to it using rabbitmqctl you get the following error (repeatedly):


macbookpro:~ timperrett$ sudo rabbitmqctl status
Status of node rabbit@macbookpro ...
{badrpc,nodedown}
...done.

The Solution

After many hours dabbling, and checking, checking again, rechecking my user and permissions setup, I found that it was actually to do with the way in which ERlang networks. Essentially, I was running the broker on:


rabbit@macbookpro

However, whilst I could ping the host “macbookpro” from terminal, it appears that Rabbit MQ needed it defined in the /etc/hosts file in order to work correctly.

Both strange and annoying, perhaps this will save someone some time!

Bongtastic load testing!!

July 8th, 2008

My mind escapes me at this late hour on a Tuesday eve, but Im fairly sure i’ve blogged about the httperf tool from HP Labs before.

Anyway, if I havent, thats a different story, as today, I want to point you good reader to the wonderfull tool that is Bong

httperf has somewhat cryptic command syntax, and bong is a really nice wrapper around it which make leveraging the full power of httperf a breeze.

Check out the Bong home page for more info – I’ll put up a quick tutorial when its not so late and my brain is functioning properly.

I’ve recently started using Amazon EC2 and put quite simply, it could well be the best computing platform the world has ever seen! Its flexible, scalable, and very competitively priced which makes it an attractive proposition for users that are currently on fixed priced virtual machine hosting.

The real differentiator with EC2 is that you are effectively building a linux machine from scratch that can be flug around there cloud to any location. So, that means you could make an image of your running machine using there AMI Tools and have your box running in East Coast America. Pretty straight forward so far. You then get wind (pun intended) that a massive hurricane is about to hit the East Coast, and you’d feel safer if your servers were far far away, right? No problem, with a simple one line command you can re-deploy the image to the West Coast cloud and everything would just pick up where it left off! Amazing!

On top of all that clever trickery, you get pretty decent control over firewall ACL’s and the choice of box configuration is pretty decent – the ‘small’ machine still has 1.7GB of RAM, which is a boat load more than most of VM’s on the market. You can even get 7.5GB and 15GB variants.

Amazon, you have out-done yourselves. Congratulations!

Just a short post for people who might not be sure how to get Wireshark to read the interfaces from your mac…

I had to run the applications as root:wheel to let the X11 interface read the network interface devices. To do the same, just run:

sudo /Applications/Wireshark.app/Contents/MacOS/Wireshark

Then, when prompted, just enter your password (provided you are a machine administrator that is). Wireshark X11 should then boot up and work without problem.

If your on 10.4 you will need to install X11 beforehand

I’ve been doing some work with NGINX of late and anyone familiar with CakePHP will know that it ships out of the box with Apache .htaccess files to make sure that the URL’s are devoid of there query string.

Anyway, enough talk, if you want to host cakephp on NGINX, you’ll need to use a vhost like so:



    server { 
        listen       80;
        server_name  somedomain.com;
        access_log  /var/www/logs/somedomain.access.log  main;
        error_log   /var/www/logs/somedomain.error.log info;
        rewrite_log on;

        # rewrite rules for cakephp
        location / {
          root   /var/www/sites/somedomain.com/current;
          index  index.php index.html;

          # If the file exists as a static file serve it 
          # directly without running all
          # the other rewite tests on it
          if (-f $request_filename) { 
            break; 
          }
          if (!-f $request_filename) {
            rewrite ^/(.+)$ /index.php?url=$1 last;
            break;
          }
        }

        location ~ \.php$ {
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME \
          /var/www/sites/somedomain.com/current$fastcgi_script_name;
          include fastcgi_params;
        }
    }

Java Is Not A Dirty Word...

April 11th, 2008

Strong title I know… It feels like thats how Java is regarded these days – Ruby and Python are becoming the golden boys of programming choice and poor ol’ java is being left out in the cold because people only remember it as having crap costing/license models where you [the developer] needed to pay for everything.

Well, I have good news for you my friends, Java should no longer be a dirty word! The inertia that Ruby on Rails had in the Java community did cause quite a lot of controversy its true, but its almost like after the initial xenophobia had worn off they sat up and thought “you know what, these guys might actually be onto something here”. I recently got into using Maven 2, and god, my good god, its a million times better than Ant, which just sucked so badly I cant explain! For anyone who is familiar with Rake, Maven is like Rake, but with all the package management stuff built right in – it does still have a certain level of entry required, but it just simplifies the process of created projects and managing dependencies in a very streamlined way.

The language itself has evolved quite a lot too – the new annotations are used heavily be JEE apps and frameworks – take CXF as an example; it will eventually replace XFire and Axis2 as the premier SOAP/WebService framework for Java, its a very very powerful tool and pretty easy to use (relatively speaking)

Anyway, I digress… my point is that if, like me, you left Java because the last time you worked with it you were slogging it out with 1.4 and Ant hell, then perhaps its time you took another look? Java has had significant investment as a platform, and there is a hell of a lot of good code out there for doing pretty much anything you can think of. In all honesty, one of the main reasons I have come back to JEE and the JVM in general is deployment – the JVM is very robust, and the containers built of top of it like Resin and Glassfish are being used in very high-concurrency environments and the deployment method via JAR or WAR is just so much more robust than on a platform like Ruby – and thats coming from having spent nearly the past 3 years solidly coding Ruby and doing all manner of deployments!

Dont write Java off – its an amazing platform, so what if its not as easy to get started as with other languages; think long-term, its a language that will grow with you rather than one you might someday reach the ceiling of – or just find incredibly annoying when the application dispatchers crash for a past time ;-)

Over and out

I have put together an all-in-one installer for Apache Maven 2.0.8 and Scala 2.7.0-final! Just download the installer, be it on 10.5 or 10.4, just download the right distro for your operating system and then follow the installation procedure.

The installer will then automatically append all the right shell variables to your $PATH so they will be freshly available from the terminal – splendid.

You can find the all in one maven installer for OSX here

Any problems feel free to get in touch.

Step 1

Run the rake task to freeze rails 2.0.2 into the project so your not reading from gems:

rake rails:freeze:gems

Step 2

Remove the database.yml file from RAILS_ROOT/config/

Step 3

Change line 21 in RAILS_ROOT/config/enviroment.rb to:

config.frameworks -= [ :active_record ]

Bobs your uncle, that should be it!

With new cross-language mash ups appearing all the time with things like JRuby and Jython it makes me wonder where all this is going? Will we have J2EE apps deployed alongside dynamic languages all within the same container, all capable of leveraging the awesome JVM runtime? If so, then wow, thats an awesome proposition. Pretty much every language you can think of is now deployable within a java container – its even possible to deploy .net applications via mono!

Perhaps people will start to standardize on the JVM as a platform – all this constant fighting over runtimes, platforms and environments makes work for the developer and architect extremely difficult; we want to keep up with the latest developments, but it just makes it so difficult to do that with all this chopping and changing.

Anyway, things I think are going to be seriously hot this year are:

Resin Application Server

Lift Framework and Scala

JRuby

Hessian Binary Remoting

We’ll see how things play out over the next few months, but whatever happens, its going to be exciting to see how all these technologies interact with each other – which fizzle out and which go on to achieve wonderful things.

Just a quick note that I have refactored the code base for the XMPie ICP extension for Merb 0.9.2 and added some extra cool things that are inherited by the ICP subclasses.

Now, its possible to add validation into the model subclass. Lets say we have a feild defined in our uPlan called ‘email’ and ‘user_name’. I need the ‘user_name’ field to be required, which you can now do like so:



class Visitor < Xmpie::Icp::Base
  validates_presence_of :user_name
end

# in your controller...
@visitor.valid? # => true if has a user_name, otherwise false


All exciting stuff! When XMPie make ICP a more viable persistance tier, then this will no doubt be the quickest and slickest way to implement front ends in. Furthermore, with the Engine Yard team working on mod_rubinus then we should see ruby web application performance finally get where it needs to be.