load testing AWS SQS with GatlingSome 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.

As of now, Gatling doesn’t have a 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 just plug onto Gatling’s native JMS support.

Importing the SQS JMS adapter library

The first thing you have to do is to add the amazon-sqs-java-messaging-lib jar in your classpath.
As an example, here are the maven coordinates you’d have to add into 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 need to 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 is to create the SQS client instance that will be 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 for a ConnectionFactory, or directly pass one you’d create programmatically. Only the latter works for SQS.

val 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 it you want to use requestReply, you have to 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!



Let us know about your project

Used by over 100,000 web applications and e-commerce websites, Gatling solution is put to use in diverse industries including Software, Streaming media, Banking, Insurance, Gaming and Finance.

Related resources

You might also be interested in…