Testing Amazon SQS locally with ElasticMQ

If you’re developing an application that uses the Amazon Simple Queue Service (SQS), you may find yourself asking how you can run and test your application locally without having to connect to the real SQS every time. At least, I did – when running our test suite was getting painfully slow.

Luckily, there is at least one option: ElasticMQ provides an SQS-compatible interface.

Starting ElasticMQ is as easy as downloading its binary package, extracting it and executing bin/run.sh.

Configuring the Amazon Java SDK to use to the local ElasticMQ instance is equally easy: just set the SQS endpoint to http://localhost:9324 – which is where ElasticMQ accepts connections by default. Voilà.

If you’re using Ruby and Cucumber for acceptance tests you can configure Amazon Ruby SDK to connect to the local ElasticMQ broker as follows:

client = AWS::SQS.new({
  :access_key_id => AWS_KEY,
  :secret_access_key => AWS_SECRET,
  :sqs_endpoint => 'localhost',
  :sqs_port => 9324,
  :use_ssl => false,

Now our tests run at least 5 times quicker, allowing for a much more pleasant test/code cycle during development.


2 thoughts on “Testing Amazon SQS locally with ElasticMQ

  1. Bruno says:

    Hi Mirko,

    I am using Javs Spring for AWS to send messages to an SQS queue. I have tried setting the endpoint to http://localhost:9324 on my AWS client instance. I have ElasticMQ running and the queue created, but the messages I send always end up in the AWS SQS queue and not the local ElasticMQ one.

    Do you have any ideas why this may be?

    I thought I’d find lots of articles online exploring this approach, but I was wrong…



Leave a Reply to chuang chen Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s