Load Testing AWS SQS with Gatling

2 min read
Jan 31, 2019 10:36:00 AM

load testing AWS SQS with Gatling

Some of our users asked about load testing AWS SQS with Gatling. Here is a step-by-step guide!

Amazon Simple Queue Service (SQS) is AWS's managed message queuing service.

Currently, Gatling doesn't have native SQS support, but still, it's fairly easy to use Gatling to load test SQS.

AWS provides a library that implements part of the Java Message Service (JMS) API.
This library is just a thin adapter layer on top of the AWS Java SDK library, so it doesn't introduce any significant overhead.
You can then plug into Gatling's native JMS support.


Importing the SQS JMS adapter library

The first thing you have to do is add the amazon-sqs-java-messaging-lib jar to your classpath.
For example, here are the maven coordinates you'd have to add to your pom.xml.

 <version>1.0.4</version> <!-- latest version at the time of this post -->

We also recommend that you upgrade the version of AWS Java SDK as the one that's being pulled transitively is a bit old:

 <version>1.11.490</version> <!-- latest version at the time of this post -->

Note that only the v1 of the AWS Java SQK is currently supported.


Creating a ConnectionFactory

Adding imports

You must add imports for SQS, the JMS SQS wrapper, and Gatling JMS DSL.

// SQS
import com.amazon.sqs.javamessaging._
import com.amazonaws.auth._
import com.amazonaws.regions._
import com.amazonaws.services.sqs._

// Gatling JMS DSL
import io.gatling.jms.Predef._


Creating the SQS Client

The first thing to do is create the SQS client instance wrapped with the JMS layer.

val sqsClient = {
 val builder = AmazonSQSAsyncClientBuilder.standard
 // configure the credentials strategy of your choice
 builder.setCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("myKey", "myToken")))

Make sure that you properly close the client and its underlying resources once the test is done, thanks to the after hook:

after {


Configuring the JmsProtocol with the ConnectionFactory

Gatling JMS support lets you either pass a JNDI configuration to look up a ConnectionFactory or directly pass one you'd create programmatically. Only the latter works for SQS.

al jmsProtocol = jms.connectionFactory(new SQSConnectionFactory(new ProviderConfiguration(), sqsClient))


Writing a JMS Scenario and Configuring the JmsProtocol on the SetUp

This step is pure Gatling JMS, please refer to the official documentation.

val scn = scenario("SQS test")

Note that SQS doesn't support temporary queues, so if you want to use requestReply, you must explicitly configure the replyQueue.


Using FIFO queues

SQS FIFO queues have the notions of Message Group ID (required) and Message Deduplication ID (optional). Those can be configured with the respective JMSXGroupID and JMS_SQS_DeduplicationId JMS properties.

 .property("JMSXGroupID", "MyMessageGroupId")


We hope this blog post helps! Let us know your feedback!