Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

ElasticMQ 0.2 – support for delayed queues and messages

DZone's Guide to

ElasticMQ 0.2 – support for delayed queues and messages

· Java Zone
Free Resource

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

I just released version 0.2 of ElasticMQ – a simple message queue system, which implements the Amazon SQS interface. Ideal if you want to test a service which uses SQS, or create a system which can leverage either the AWS infrastructure or run stand-alone.

The new version brings support for some new Amazon SQS features: delayed messages and queues. See the Amazon Blog for details.

Also, I changed the testsuite to use Amazon’s Java SDK. So you can be pretty sure that ElasticMQ works with SQS clients :). As an example, here’s the required code (in Scala, Java equivalent would be obviously a bit longer ;) ) to start an ElasticMQ node, send & receive a message using Amazon Java SDK and shutdown the server.

// First we need to create a Node
val node = NodeBuilder.withInMemoryStorage().build()
// Then we can expose the native client using the SQS REST interface
val server = SQSRestServerFactory.start(node.nativeClient, 8888,
      "http://localhost:8888")
 
// Now we need to create the sqs client
client = new AmazonSQSClient(new BasicAWSCredentials("x", "x"))
client.setEndpoint("http://localhost:8888")
 
// Using the client is quite straightforward
val queueUrl = client.createQueue(new CreateQueueRequest("queue1"))
      .getQueueUrl
client.sendMessage(new SendMessageRequest(queueUrl, "message1"))
 
client.shutdown()
 
// Finally we need to stop the server and the node
server.stop()
node.shutdown()

For more information about ElasticMQ, information on SBT and Maven dependencies, see the webpage.

Stay tuned,
Adam

 

From http://www.warski.org/blog/2012/01/elasticmq-0-2-support-for-delayed-queues-and-messages/

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}