ElasticMQ
repository·master·Indexed 25 days ago
https://github.com/softwaremill/elasticmqAn in-memory message queue system providing an Amazon SQS-compatible REST interface. Designed for testing and local development, it can be run as a standalone service via Docker, embedded in Scala applications, or as an actor-based system. Features include an optional monitoring UI, queue persistence via SQL databases, and support for FIFO queues.
What's inside ElasticMQ
- ElasticMQ is an in-memory message queue system that provides an Amazon SQS-compatible REST (query) interface. It is fully asynchronous and can be run as a standalone service via Docker, embedded in an application, or as a Scala actor-based system. It supports optional UI for monitoring and queue persistence.
Build multi-architecture Docker images
masterYou can build Docker images for bothamd64andarm64using the Docker Buildx plugin. This requires creating a Buildx instance and using the--platformflag. Note that when usingbuildx, you must use the--pushflag to store the image in a registry, as--loadonly supports single-architecture images.Run ElasticMQ locally with Docker Compose
masterThe easiest way to run ElasticMQ locally is using Docker Compose. This starts both the SQS-compatible REST API and the Web UI.
- SQS API: Port
9324(softwaremill/elasticmq-native) - Web UI: Port
3000(softwaremill/elasticmq-ui)
After starting, access the UI at http://localhost:3000 to view queues, send messages, and monitor statistics. The configuration is loaded from
examples/elasticmq.confand data is persisted in a Docker volume namedelasticmq-data.docker compose up- SQS API: Port
Start an embedded ElasticMQ server in Scala
masterTo use ElasticMQ as an embedded server within a Scala application, add the
elasticmq-rest-sqsmodule to yourbuild.sbtdependencies. You can start the server using a configuration file or via theSQSRestServerBuilderfor more programmatic control.// Add to build.sbt libraryDependencies += "org.elasticmq" %% "elasticmq-rest-sqs" % Version // Option 1: Using a configuration file val config = ConfigFactory.load("elasticmq.conf") val server = new ElasticMQServer(new ElasticMQServerConfig(config)) server.start() // Option 2: Using SQSRestServerBuilder val server = SQSRestServerBuilder.start() // ... use ... server.stopAndWait()Manage ElasticMQ via the Web UI
masterElasticMQ includes a web UI for monitoring and managing queues.
- Docker Compose: The UI starts automatically at
http://localhost:3000. - Local Development: Run
npm installandnpm run devinside theuidirectory. The dev server expects ElasticMQ athttp://localhost:9324(configurable viaui/.env.local). - Real AWS Integration: You can point the UI at a real AWS account by setting
AWS_REGION,AWS_ACCESS_KEY_ID, andAWS_SECRET_ACCESS_KEYinui/.env.localand leavingSQS_ENDPOINTunset.
- Docker Compose: The UI starts automatically at
Quick Start: Running ElasticMQ Integration Tests (Node.js)
masterTo run the integration tests for ElasticMQ using the AWS SDK for JavaScript v3, you can choose between using a local server (fastest) or Docker containers (full integration).
Prerequisites
- Node.js 18+
- Docker (for container mode)
- ElasticMQ Docker image (e.g.,
softwaremill/elasticmq:latest)
Option 1: Local Server Mode (Fastest)
- Start ElasticMQ locally:
docker run -p 9324:9324 softwaremill/elasticmq:latest - Run tests:
npm install npm run test:local
Option 2: Docker Container Mode (Full Integration)
- Pull the required image:
docker pull softwaremill/elasticmq:latest - Run tests:
npm install npm test
# Local Server Mode docker run -p 9324:9324 softwaremill/elasticmq:latest npm install npm run test:local # Docker Container Mode docker pull softwaremill/elasticmq:latest npm install npm testAdd ElasticMQ dependencies (SBT and Maven)
masterTo use the SQS-compatible REST interface, include the
elasticmq-rest-sqsdependency. If you only need the actor-based core, useelasticmq-core.// Scala 2.13 and 2.12 val elasticmqSqs = "org.elasticmq" %% "elasticmq-rest-sqs" % Version // Core only val elasticmqCore = "org.elasticmq" %% "elasticmq-core" % Version<!-- Maven --> <dependency> <groupId>org.elasticmq</groupId> <artifactId>elasticmq-rest-sqs_2.12</artifactId> <version>${version}</version> </dependency>Run ElasticMQ with debug mode
masterTo build and run the server with a remote debugger enabled on port 5005, use the following sbt command:
~/workspace/elasticmq $ sbt -jvm-debug 5005 > project server > runAutomatically create queues on startup
masterYou can pre-define queues and their attributes in a configuration file. Attributes like
defaultVisibilityTimeout,delay, anddeadLettersQueueare optional.To create a FIFO queue, set
fifo = true. If the queue name ends with.fifo, the suffix is added automatically if not already present.Special attributes for testing:
copyTo: Duplicates messages to another queue.moveTo: Redirects messages to another queue.
queues { queue1 { defaultVisibilityTimeout = 10 seconds delay = 5 seconds receiveMessageWait = 0 seconds deadLettersQueue { name = "queue1-dead-letters" maxReceiveCount = 3 } fifo = false contentBasedDeduplication = false copyTo = "audit-queue-name" moveTo = "redirect-queue-name" tags { tag1 = "tagged1" tag2 = "tagged2" } } queue1-dead-letters { } audit-queue-name { } redirect-queue-name { } }Build a jar-with-dependencies
masterTo create an assembly jar containing all dependencies, run the
assemblycommand within sbt:~/workspace/elasticmq $ sbt > project server > assemblyConfigure Web UI feature flags
masterUse the following environment variable inui/.env.localto control UI behavior, especially when connecting to real AWS accounts to save on API costs.Persist queue metadata to a configuration file
masterYou can persist queue metadata (names and attributes, but not messages) to an external HOCON file. This file is updated whenever a queue is created, deleted, or modified. On startup, queues defined in this file take precedence over those in the main configuration.
include classpath("application.conf") queues-storage { enabled = true path = "/path/to/storage/queues.conf" }