### Start Embedded ElasticMQ Server (SBT) Source: https://github.com/softwaremill/elasticmq/blob/master/README.md Provides Scala code examples for starting an embedded ElasticMQ server using SBT. It shows how to use custom configurations or the SQSRestServerBuilder with various options like port, interface, and dynamic port. ```scala libraryDependencies += "org.elasticmq" %% "elasticmq-rest-sqs" % Version ``` ```scala val config = ConfigFactory.load("elasticmq.conf") val server = new ElasticMQServer(new ElasticMQServerConfig(config)) server.start() ``` ```scala val server = SQSRestServerBuilder.start() // ... use ... server.stopAndWait() ``` ```scala val server = SQSRestServerBuilder.withPort(9325).withInterface("localhost").start() // ... use ... server.stopAndWait() ``` ```scala val server = SQSRestServerBuilder.withDynamicPort().start() server.waitUntilStarted().localAddress().getPort() ``` -------------------------------- ### Starting an Embedded ElasticMQ Server Source: https://github.com/softwaremill/elasticmq/blob/master/README.md Instructions and code examples for starting an embedded ElasticMQ server with an SQS interface. ```APIDOC ## Starting an Embedded ElasticMQ Server ### Description Start an embedded ElasticMQ server with an SQS interface using Scala code. ### Method 1: Using Custom Configuration Add the `elasticmq-rest-sqs` module to your `build.sbt`: ```scala libraryDependencies += "org.elasticmq" %% "elasticmq-rest-sqs" % Version ``` Start the server with custom configuration: ```scala import com.typesafe.config.ConfigFactory import org.elasticmq.server.ElasticMQServer import org.elasticmq.server.ElasticMQServerConfig val config = ConfigFactory.load("elasticmq.conf") val server = new ElasticMQServer(new ElasticMQServerConfig(config)) server.start() ``` ### Method 2: Using `SQSRestServerBuilder` This builder does not load configuration files. Queues must be created programmatically. **Basic Start:** ```scala import org.elasticmq.rest.SQSRestServerBuilder val server = SQSRestServerBuilder.start() // ... use the server ... server.stopAndWait() ``` **Custom Host/Port:** ```scala val server = SQSRestServerBuilder.withPort(9325).withInterface("localhost").start() // ... use the server ... server.stopAndWait() ``` **Dynamic Port:** ```scala val server = SQSRestServerBuilder.withDynamicPort().start() // Retrieve the port after the server has started val port = server.waitUntilStarted().localAddress().getPort() ``` **Custom ActorSystem:** Refer to javadocs for details on providing a custom `ActorSystem`. ``` -------------------------------- ### Download and Run ElasticMQ Server Source: https://github.com/softwaremill/elasticmq/blob/master/README.md Commands to download the ElasticMQ JAR file and start the server using the Java runtime. ```bash wget https://s3-eu-west-1.amazonaws.com/softwaremill-public/elasticmq-server-$VERSION.jar java -jar elasticmq-server-$VERSION.jar ``` -------------------------------- ### Start ElasticMQ Server via Docker Source: https://github.com/softwaremill/elasticmq/blob/master/integration-tests/nodejs/README.md Commands to launch an ElasticMQ instance using Docker. This is required for local testing or as a dependency for integration tests. ```bash docker run -p 9324:9324 softwaremill/elasticmq:latest ``` -------------------------------- ### Run Jest Tests with Options Source: https://github.com/softwaremill/elasticmq/blob/master/integration-tests/nodejs/README.md Example of running tests with specific Jest flags like verbose output and serial execution. ```bash npm test -- --runInBand --verbose integration.test.js ``` -------------------------------- ### Create SQS Queue via API Source: https://context7.com/softwaremill/elasticmq/llms.txt Example curl command to create a new SQS queue on a running ElasticMQ instance. ```bash curl -X POST "http://localhost:9324/" -d "Action=CreateQueue" -d "QueueName=my-queue" ``` -------------------------------- ### Configure ElasticMQ with HOCON Source: https://context7.com/softwaremill/elasticmq/llms.txt Example HOCON configuration file defining node settings, REST interfaces, AWS region details, queue definitions, and persistence storage options. ```hocon include classpath("application.conf") node-address { protocol = http; host = localhost; port = 9324; context-path = "" } rest-sqs { enabled = true; bind-port = 9324; bind-hostname = "0.0.0.0"; sqs-limits = strict } rest-stats { enabled = true; bind-port = 9325; bind-hostname = "0.0.0.0" } aws { region = us-west-2; accountId = 000000000000 } queues { my-queue { defaultVisibilityTimeout = 30 seconds; delay = 0 seconds; receiveMessageWait = 0 seconds; fifo = false; contentBasedDeduplication = false; tags { environment = "development" } }; my-dlq { }; my-queue-with-dlq { defaultVisibilityTimeout = 30 seconds; deadLettersQueue { name = "my-dlq"; maxReceiveCount = 3 } }; "my-fifo-queue.fifo" { fifo = true; contentBasedDeduplication = true } } queues-storage { enabled = true; path = "/data/queues.conf" } messages-storage { enabled = true; uri = "jdbc:h2:/data/elasticmq" } ``` -------------------------------- ### ElasticMQ Configuration Schema Source: https://github.com/softwaremill/elasticmq/blob/master/README.md Example configuration structure for defining node addresses, REST SQS settings, and queue storage using Typesafe Config. ```hocon include classpath("application.conf") node-address { protocol = http host = localhost port = 9324 context-path = "" } rest-sqs { enabled = true bind-port = 9324 bind-hostname = "0.0.0.0" sqs-limits = strict } rest-stats { enabled = true bind-port = 9325 bind-hostname = "0.0.0.0" } aws { region = us-west-2 accountId = 000000000000 } ``` -------------------------------- ### Access ElasticMQ with Amazon boto (Python) Source: https://github.com/softwaremill/elasticmq/blob/master/README.md Provides Python code examples for connecting to an ElasticMQ server using both the older 'boto' library and the newer 'boto3' library, specifying endpoint, port, and credentials. ```python region = boto.sqs.regioninfo.RegionInfo(name='elasticmq', endpoint=sqs_endpoint) conn = boto.connect_sqs(aws_access_key_id='x', aws_secret_access_key='x', is_secure=False, port=sqs_port, region=region) ``` ```python client = boto3.resource('sqs', endpoint_url='http://localhost:9324', region_name='elasticmq', aws_secret_access_key='x', aws_access_key_id='x', use_ssl=False) queue = client.get_queue_by_name(QueueName='queue1') ``` -------------------------------- ### Start Message Move Task via cURL Source: https://context7.com/softwaremill/elasticmq/llms.txt Initiate a task to move messages from a dead letter queue back to the source or a designated destination queue. ```bash curl -X POST "http://localhost:9324/" \ -d "Action=StartMessageMoveTask" \ -d "SourceArn=arn:aws:sqs:us-west-2:000000000000:my-dlq" curl -X POST "http://localhost:9324/" \ -d "Action=StartMessageMoveTask" \ -d "SourceArn=arn:aws:sqs:us-west-2:000000000000:my-dlq" \ -d "DestinationArn=arn:aws:sqs:us-west-2:000000000000:reprocess-queue" \ -d "MaxNumberOfMessagesPerSecond=10" ``` -------------------------------- ### Receive Messages from ElasticMQ (curl) Source: https://context7.com/softwaremill/elasticmq/llms.txt Provides examples of receiving messages from an ElasticMQ queue using curl. Demonstrates receiving a single message and receiving multiple messages with long polling and configurable visibility timeout. ```bash # Receive a single message curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=ReceiveMessage" ``` ```bash # Receive multiple messages with long polling curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=ReceiveMessage" \ -d "MaxNumberOfMessages=10" \ -d "WaitTimeSeconds=20" \ -d "VisibilityTimeout=60" ``` -------------------------------- ### Get Queue Attributes (curl) Source: https://context7.com/softwaremill/elasticmq/llms.txt Demonstrates how to retrieve attributes of a queue using cURL. You can fetch all attributes or specify particular ones like message counts and visibility timeout. ```bash curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=GetQueueAttributes" \ -d "AttributeName.1=All" ``` ```bash curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=GetQueueAttributes" \ -d "AttributeName.1=ApproximateNumberOfMessages" \ -d "AttributeName.2=ApproximateNumberOfMessagesNotVisible" \ -d "AttributeName.3=VisibilityTimeout" \ -d "AttributeName.4=QueueArn" ``` -------------------------------- ### Send Messages to ElasticMQ (curl) Source: https://context7.com/softwaremill/elasticmq/llms.txt Examples of sending messages to an ElasticMQ queue using curl. Covers sending simple messages, messages with delays, messages with custom attributes, and messages to FIFO queues with group and deduplication IDs. ```bash # Send a simple message curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=SendMessage" \ -d "MessageBody=Hello%20World" ``` ```bash # Send message with delay curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=SendMessage" \ -d "MessageBody=Delayed%20message" \ -d "DelaySeconds=30" ``` ```bash # Send message with attributes curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=SendMessage" \ -d "MessageBody=Message%20with%20attributes" \ -d "MessageAttribute.1.Name=Author" \ -d "MessageAttribute.1.Value.DataType=String" \ -d "MessageAttribute.1.Value.StringValue=JohnDoe" \ -d "MessageAttribute.2.Name=Priority" \ -d "MessageAttribute.2.Value.DataType=Number" \ -d "MessageAttribute.2.Value.StringValue=1" ``` ```bash # Send message to FIFO queue curl -X POST "http://localhost:9324/000000000000/my-queue.fifo" \ -d "Action=SendMessage" \ -d "MessageBody=FIFO%20message" \ -d "MessageGroupId=group-1" \ -d "MessageDeduplicationId=unique-id-123" ``` -------------------------------- ### Get Queue URL (curl) Source: https://context7.com/softwaremill/elasticmq/llms.txt Provides the cURL command to retrieve the URL of a specific queue by its name. This URL is essential for performing operations on the queue. ```bash curl -X POST "http://localhost:9324/" \ -d "Action=GetQueueUrl" \ -d "QueueName=my-queue" ``` -------------------------------- ### Initialize ElasticMqContainer Source: https://github.com/softwaremill/elasticmq/blob/master/integration-tests/nodejs/README.md Demonstrates how to instantiate the ElasticMqContainer class with default settings, custom images, or local server overrides. ```javascript import { ElasticMqContainer } from '../src/elasticmq-container.js'; // Simple usage - automatically detects mode from environment variables const container = new ElasticMqContainer('messages-storage'); // Override image (ignores ELASTICMQ_IMAGE env var) const container = new ElasticMqContainer('messages-storage', { image: 'elasticmq-int:latest' }); // Force local server mode (ignores USE_LOCAL_SERVER env var) const container = new ElasticMqContainer('messages-storage', { useLocalServer: true, localEndpoint: 'http://localhost:9324' }); ``` -------------------------------- ### Configure and Use ElasticMQ with AWS SDKs Source: https://context7.com/softwaremill/elasticmq/llms.txt Demonstrates how to initialize an SQS client pointing to a local ElasticMQ endpoint and perform standard operations like creating queues, sending messages, and receiving messages. ```java import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.client.builder.AwsClientBuilder; import com.amazonaws.services.sqs.AmazonSQS; import com.amazonaws.services.sqs.AmazonSQSClientBuilder; import com.amazonaws.services.sqs.model.*; String endpoint = "http://localhost:9324"; String region = "elasticmq"; String accessKey = "x"; String secretKey = "x"; AmazonSQS client = AmazonSQSClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider( new BasicAWSCredentials(accessKey, secretKey))) .withEndpointConfiguration( new AwsClientBuilder.EndpointConfiguration(endpoint, region)) .build(); CreateQueueResult createResult = client.createQueue( new CreateQueueRequest("my-queue") .addAttributesEntry("VisibilityTimeout", "30")); String queueUrl = createResult.getQueueUrl(); SendMessageResult sendResult = client.sendMessage( new SendMessageRequest(queueUrl, "Hello from Java SDK")); System.out.println("Message ID: " + sendResult.getMessageId()); ReceiveMessageResult receiveResult = client.receiveMessage( new ReceiveMessageRequest(queueUrl) .withMaxNumberOfMessages(10) .withWaitTimeSeconds(5)); for (Message message : receiveResult.getMessages()) { System.out.println("Body: " + message.getBody()); client.deleteMessage(queueUrl, message.getReceiptHandle()); } ``` ```python import boto3 sqs = boto3.resource('sqs', endpoint_url='http://localhost:9324', region_name='elasticmq', aws_access_key_id='x', aws_secret_access_key='x', use_ssl=False) queue = sqs.create_queue( QueueName='my-queue', Attributes={'VisibilityTimeout': '30', 'ReceiveMessageWaitTimeSeconds': '20'}) queue.send_message(MessageBody='Hello from Python') messages = queue.receive_messages(MaxNumberOfMessages=10, WaitTimeSeconds=5) for message in messages: print(f"Body: {message.body}") message.delete() client = boto3.client('sqs', endpoint_url='http://localhost:9324', region_name='elasticmq', aws_access_key_id='x', aws_secret_access_key='x') response = client.list_queues() for url in response.get('QueueUrls', []): print(f"Queue: {url}") ``` -------------------------------- ### Configure ElasticMQ Server Source: https://github.com/softwaremill/elasticmq/blob/master/README.md How to provide custom configuration files to the ElasticMQ server using system properties. ```bash java -Dconfig.file=custom.conf -jar elasticmq-server-$VERSION.jar java -Dlogback.configurationFile=my_logback.xml -jar elasticmq-server-$VERSION.jar ``` -------------------------------- ### Configure ElasticMQ Container in JavaScript Source: https://github.com/softwaremill/elasticmq/blob/master/integration-tests/nodejs/README.md Demonstrates how to instantiate the ElasticMqContainer class in Node.js. This allows for programmatic control over the container image and environment settings. ```javascript import { ElasticMqContainer } from '../src/elasticmq-container.js'; const container = new ElasticMqContainer('messages-storage', { image: 'softwaremill/elasticmq-native:latest' }); await container.start(); ``` -------------------------------- ### Run ElasticMQ Standalone Server Source: https://context7.com/softwaremill/elasticmq/llms.txt Commands to download and execute the ElasticMQ server JAR file. Supports custom configuration files via JVM system properties. ```bash wget https://s3-eu-west-1.amazonaws.com/softwaremill-public/elasticmq-server-1.6.0.jar java -jar elasticmq-server-1.6.0.jar java -Dconfig.file=custom.conf -jar elasticmq-server-1.6.0.jar ``` -------------------------------- ### List Queues (curl) Source: https://context7.com/softwaremill/elasticmq/llms.txt Shows how to list all available queues or filter them by a name prefix using cURL. The response provides the URLs of the queues. ```bash curl -X POST "http://localhost:9324/" \ -d "Action=ListQueues" ``` ```bash curl -X POST "http://localhost:9324/" \ -d "Action=ListQueues" \ -d "QueueNamePrefix=prod-" ``` -------------------------------- ### Create ElasticMQ Queues with Attributes (curl) Source: https://context7.com/softwaremill/elasticmq/llms.txt Demonstrates creating various types of queues in ElasticMQ using curl. This includes queues with custom attributes like VisibilityTimeout, DelaySeconds, and ReceiveMessageWaitTimeSeconds, as well as FIFO queues with ContentBasedDeduplication, and queues configured with a dead-letter queue. ```bash curl -X POST "http://localhost:9324/" \ -d "Action=CreateQueue" \ -d "QueueName=my-queue" \ -d "Attribute.1.Name=VisibilityTimeout" \ -d "Attribute.1.Value=60" \ -d "Attribute.2.Name=DelaySeconds" \ -d "Attribute.2.Value=5" \ -d "Attribute.3.Name=ReceiveMessageWaitTimeSeconds" \ -d "Attribute.3.Value=20" ``` ```bash curl -X POST "http://localhost:9324/" \ -d "Action=CreateQueue" \ -d "QueueName=my-queue.fifo" \ -d "Attribute.1.Name=FifoQueue" \ -d "Attribute.1.Value=true" \ -d "Attribute.2.Name=ContentBasedDeduplication" \ -d "Attribute.2.Value=true" ``` ```bash curl -X POST "http://localhost:9324/" \ -d "Action=CreateQueue" \ -d "QueueName=my-queue" \ -d 'Attribute.1.Name=RedrivePolicy' \ -d 'Attribute.1.Value={"deadLetterTargetArn":"arn:aws:sqs:us-west-2:000000000000:my-dlq","maxReceiveCount":"3"}' ``` -------------------------------- ### Run ElasticMQ via Docker Source: https://context7.com/softwaremill/elasticmq/llms.txt Commands to deploy ElasticMQ using Docker images. Includes options for native images, custom configurations, and persistent storage volumes. ```bash docker run -p 9324:9324 -p 9325:9325 softwaremill/elasticmq-native docker run -p 9324:9324 -p 9325:9325 -v `pwd`/custom.conf:/opt/elasticmq.conf softwaremill/elasticmq-native docker run -p 9324:9324 -p 9325:9325 -v `pwd`/custom.conf:/opt/elasticmq.conf -v `pwd`/data:/data softwaremill/elasticmq-native docker run -p 9324:9324 -p 9325:9325 softwaremill/elasticmq ``` -------------------------------- ### Logging Configuration Source: https://github.com/softwaremill/elasticmq/blob/master/README.md Information on ElasticMQ's logging implementation and recommendations. ```APIDOC ## Logging ### Description ElasticMQ uses Slf4j for logging. By default, no logger backend is included. Logback is recommended. ### Configuration No specific configuration code is provided, but it relies on Slf4j implementation (e.g., Logback) configuration. ``` -------------------------------- ### Receive Messages with Attributes (curl) Source: https://context7.com/softwaremill/elasticmq/llms.txt Demonstrates how to receive messages from a queue using cURL. It shows how to request all system attributes or specific attributes like SentTimestamp and ApproximateReceiveCount, along with message attributes. ```bash curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=ReceiveMessage" \ -d "AttributeName.1=All" ``` ```bash curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=ReceiveMessage" \ -d "AttributeName.1=SentTimestamp" \ -d "AttributeName.2=ApproximateReceiveCount" \ -d "MessageAttributeName.1=All" ``` -------------------------------- ### Using Amazon boto (Python) with ElasticMQ Source: https://github.com/softwaremill/elasticmq/blob/master/README.md How to configure the Amazon boto and boto3 libraries to connect to an ElasticMQ server. ```APIDOC ## Using the Amazon boto (Python) to access an ElasticMQ Server ### Description Configure the Amazon boto and boto3 libraries in Python to connect to an ElasticMQ server. ### Using `boto` (legacy) ```python import boto from boto.sqs.regioninfo import RegionInfo sqs_endpoint = 'localhost' # Replace with your ElasticMQ server host sqs_port = 9324 # Replace with your ElasticMQ server port region = RegionInfo(name='elasticmq', endpoint=sqs_endpoint) conn = boto.connect_sqs( aws_access_key_id='x', # Replace with your access key aws_secret_access_key='x', # Replace with your secret key is_secure=False, port=sqs_port, region=region ) # Now you can use 'conn' to interact with ElasticMQ ``` ### Using `boto3` (current) ```python import boto3 endpoint_url = 'http://localhost:9324' # Replace with your ElasticMQ server endpoint client = boto3.resource( 'sqs', endpoint_url=endpoint_url, region_name='elasticmq', aws_secret_access_key='x', # Replace with your access key aws_access_key_id='x', # Replace with your secret key use_ssl=False ) # Example: Get a queue queue = client.get_queue_by_name(QueueName='queue1') ``` ``` -------------------------------- ### Run Jest Tests with Patterns Source: https://github.com/softwaremill/elasticmq/blob/master/integration-tests/nodejs/README.md Commands to execute specific test files, suites, or cases using Jest CLI arguments. ```bash npm test integration.test.js npm test -- -t "Message Storage" npm test -- -t "should persist messages after restart" npm test -- --testNamePattern="Queue Storage" npm test integration.test.js -- -t "Dead Letter" ``` -------------------------------- ### StartMessageMoveTask API Source: https://context7.com/softwaremill/elasticmq/llms.txt Move messages from a dead letter queue back to the source queue or to a specified destination queue for reprocessing. ```APIDOC ## StartMessageMoveTask API ### Description Move messages from a dead letter queue back to the source queue or to a specified destination queue for reprocessing. ### Method POST ### Endpoint `http://localhost:9324/` ### Parameters #### Query Parameters - **Action** (string) - Required - `StartMessageMoveTask` - **SourceArn** (string) - Required - The ARN of the dead letter queue to move messages from. - **DestinationArn** (string) - Optional - The ARN of the destination queue. If not provided, messages are moved back to the source queue. - **MaxNumberOfMessagesPerSecond** (integer) - Optional - The maximum number of messages to move per second. ### Request Example ```bash # Move messages back to source queue curl -X POST "http://localhost:9324/" \ -d "Action=StartMessageMoveTask" \ -d "SourceArn=arn:aws:sqs:us-west-2:000000000000:my-dlq" # Move messages to specific destination curl -X POST "http://localhost:9324/" \ -d "Action=StartMessageMoveTask" \ -d "SourceArn=arn:aws:sqs:us-west-2:000000000000:my-dlq" \ -d "DestinationArn=arn:aws:sqs:us-west-2:000000000000:reprocess-queue" \ -d "MaxNumberOfMessagesPerSecond=10" ``` ### Response #### Success Response (200) - **TaskHandle** (string) - A handle for the message move task. #### Response Example ```xml task-handle-123 ``` ``` -------------------------------- ### Using Amazon Java SDK with ElasticMQ Source: https://github.com/softwaremill/elasticmq/blob/master/README.md How to configure the Amazon Java SDK to connect to an ElasticMQ server. ```APIDOC ## Using the Amazon Java SDK to access an ElasticMQ Server ### Description Configure the Amazon Java SDK to connect to an ElasticMQ server by setting the endpoint and credentials. ### Code Example ```java import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.client.builder.AwsClientBuilder; import com.amazonaws.services.sqs.AmazonSQS; import com.amazonaws.services.sqs.AmazonSQSClientBuilder; String endpoint = "http://localhost:9324"; // Replace with your ElasticMQ server endpoint String region = "elasticmq"; // Typically 'elasticmq' for ElasticMQ String accessKey = "x"; // Replace with your access key String secretKey = "x"; // Replace with your secret key AmazonSQS client = AmazonSQSClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey))) .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region)) .build(); // Now you can use the 'client' to interact with ElasticMQ ``` ### Notes - The endpoint should match the `NodeAddress` used when starting the ElasticMQ server. - The `rest-sqs-testing-amazon-java-sdk` module contains more usage examples. ``` -------------------------------- ### AWS SDK Integration with ElasticMQ (Node.js) Source: https://context7.com/softwaremill/elasticmq/llms.txt Demonstrates how to use the AWS SDK for JavaScript v3 to interact with ElasticMQ. It covers client configuration for a local endpoint, creating queues, sending messages (with and without attributes), receiving messages, processing and deleting them, and listing all queues. Requires `@aws-sdk/client-sqs`. ```javascript import { SQSClient, CreateQueueCommand, SendMessageCommand, ReceiveMessageCommand, DeleteMessageCommand, ListQueuesCommand } from '@aws-sdk/client-sqs'; // Configure client for ElasticMQ const sqsClient = new SQSClient({ endpoint: 'http://localhost:9324', region: 'elasticmq', credentials: { accessKeyId: 'x', secretAccessKey: 'x' } }); // Create a queue const createResponse = await sqsClient.send( new CreateQueueCommand({ QueueName: 'test-queue', Attributes: { VisibilityTimeout: '30' } }) ); const queueUrl = createResponse.QueueUrl; console.log(`Created queue: ${queueUrl}`); // Send a message await sqsClient.send( new SendMessageCommand({ QueueUrl: queueUrl, MessageBody: 'Hello from Node.js' }) ); // Send message with attributes await sqsClient.send( new SendMessageCommand({ QueueUrl: queueUrl, MessageBody: 'Message with attributes', MessageAttributes: { 'Author': { DataType: 'String', StringValue: 'TestUser' }, 'Priority': { DataType: 'Number', StringValue: '1' } } }) ); // Receive messages const receiveResponse = await sqsClient.send( new ReceiveMessageCommand({ QueueUrl: queueUrl, MaxNumberOfMessages: 10, WaitTimeSeconds: 5, MessageAttributeNames: ['All'] }) ); // Process and delete messages for (const message of receiveResponse.Messages || []) { console.log(`Body: ${message.Body}`); await sqsClient.send( new DeleteMessageCommand({ QueueUrl: queueUrl, ReceiptHandle: message.ReceiptHandle }) ); } // List all queues const listResponse = await sqsClient.send(new ListQueuesCommand({})); console.log('Queues:', listResponse.QueueUrls); ``` -------------------------------- ### Access ElasticMQ with Amazon Java SDK Source: https://github.com/softwaremill/elasticmq/blob/master/README.md Shows how to configure and use the Amazon Java SDK to interact with an ElasticMQ server by setting a custom endpoint, region, and credentials. ```java String endpoint = "http://localhost:9324"; String region = "elasticmq"; String accessKey = "x"; String secretKey = "x"; AmazonSQS client = AmazonSQSClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey))) .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region)) .build(); ``` -------------------------------- ### Embed ElasticMQ in Scala Source: https://context7.com/softwaremill/elasticmq/llms.txt Programmatic initialization of the ElasticMQ server within a Scala application using the SQSRestServerBuilder. Allows for dynamic port assignment and custom SQS limit configurations. ```scala import org.elasticmq.rest.sqs.SQSRestServerBuilder val server = SQSRestServerBuilder.start() val server = SQSRestServerBuilder.withPort(9325).withInterface("localhost").start() val server = SQSRestServerBuilder.withDynamicPort().start() val server = SQSRestServerBuilder.withInterface("0.0.0.0").withPort(9324).withSQSLimits(StrictSQSLimits).withAWSRegion("us-east-1").withAWSAccountId("123456789012").start() server.stopAndWait() ``` -------------------------------- ### Run ElasticMQ Tests via NPM Source: https://github.com/softwaremill/elasticmq/blob/master/integration-tests/nodejs/README.md Common npm scripts used to execute tests in different modes, including containerized, native, and local server configurations. ```bash npm install npm test npm run test:native npm run test:local ``` -------------------------------- ### SBT Dependencies for ElasticMQ (Scala) Source: https://context7.com/softwaremill/elasticmq/llms.txt Specifies the SBT dependencies required to integrate ElasticMQ into a Scala project. It includes options for the SQS REST interface (which bundles the core functionality) and for direct actor-based access to the core ElasticMQ components. Also shows how to add snapshot repositories. ```scala // build.sbt // For SQS REST interface (includes core) libraryDependencies += "org.elasticmq" %% "elasticmq-rest-sqs" % "1.6.0" // For core actor-based access only (without REST interface) libraryDependencies += "org.elasticmq" %% "elasticmq-core" % "1.6.0" // For snapshot versions, add Sonatype repository resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/" ``` -------------------------------- ### Set Environment Variables for Test Execution Source: https://github.com/softwaremill/elasticmq/blob/master/integration-tests/nodejs/README.md Shows how to override default test behavior using environment variables such as ELASTICMQ_IMAGE or USE_LOCAL_SERVER. ```bash ELASTICMQ_IMAGE=softwaremill/elasticmq-native:latest npm test USE_LOCAL_SERVER=true LOCAL_ENDPOINT=http://localhost:9999 npm test ``` -------------------------------- ### Constructor: ElasticMqContainer Source: https://github.com/softwaremill/elasticmq/blob/master/integration-tests/nodejs/README.md Initializes the ElasticMqContainer class to manage the lifecycle of an ElasticMQ instance for testing purposes. ```APIDOC ## Constructor: ElasticMqContainer ### Description Initializes a new wrapper for managing an ElasticMQ Docker container or local server instance. ### Method Constructor ### Parameters #### Path Parameters - **confBaseName** (string) - Required - Configuration file base name (e.g., 'messages-storage') without .conf extension. #### Request Body - **options** (object) - Optional - Configuration object. - **image** (string) - Optional - Docker image to use. Default: process.env.ELASTICMQ_IMAGE || 'softwaremill/elasticmq:latest' - **useLocalServer** (boolean) - Optional - Use local server instead of Docker. Default: false - **localEndpoint** (string) - Optional - Local server endpoint URL. Default: 'http://localhost:9324' ### Request Example ```javascript const container = new ElasticMqContainer('messages-storage', { image: 'elasticmq-int:latest', useLocalServer: false }); ``` ``` -------------------------------- ### ElasticMQ Dependencies (SBT) Source: https://github.com/softwaremill/elasticmq/blob/master/README.md How to add ElasticMQ SQS REST interface or core module dependencies to your SBT project. ```APIDOC ## ElasticMQ Dependencies (SBT) ### Description Add ElasticMQ SQS REST interface or core module dependencies to your SBT project. ### Code Example ```scala // Scala 2.13 and 2.12 val elasticmqSqs = "org.elasticmq" %% "elasticmq-rest-sqs" % Version // Core module only val elasticmqCore = "org.elasticmq" %% "elasticmq-core" % Version ``` ### Snapshot Versions To use snapshot versions, add the following repository: ``` https://oss.sonatype.org/content/repositories/snapshots/ ``` ``` -------------------------------- ### POST / ListQueues Source: https://context7.com/softwaremill/elasticmq/llms.txt Returns a list of all queues associated with the account, with optional prefix filtering. ```APIDOC ## POST / ListQueues ### Description Lists all available queues. ### Method POST ### Endpoint / ### Parameters #### Request Body - **Action** (string) - Required - Must be 'ListQueues' - **QueueNamePrefix** (string) - Optional - Filter queues by name prefix. ### Request Example curl -X POST "http://localhost:9324/" -d "Action=ListQueues" ``` -------------------------------- ### Maven Dependencies for ElasticMQ (Java) Source: https://context7.com/softwaremill/elasticmq/llms.txt Provides the Maven dependency configuration for including ElasticMQ in a Java project, specifically for embedded usage. It lists the artifact for the SQS REST interface and includes instructions for adding snapshot repositories. ```xml org.elasticmq elasticmq-rest-sqs_2.13 1.6.0 sonatype-snapshots https://oss.sonatype.org/content/repositories/snapshots/ ``` -------------------------------- ### Test Execution Commands Source: https://github.com/softwaremill/elasticmq/blob/master/integration-tests/nodejs/README.md CLI commands for running specific tests or suites using Jest within the integration framework. ```APIDOC ## CLI: Running Tests ### Description Commands to execute specific test files, suites, or patterns using the npm test script. ### Usage - **Run specific file**: `npm test integration.test.js` - **Run specific suite**: `npm test -- -t "Message Storage"` - **Run with verbose output**: `npm test -- --verbose` - **Run serially**: `npm test -- --runInBand` ### Environment Variables - **ELASTICMQ_IMAGE** (string) - Override default Docker image. - **USE_LOCAL_SERVER** (boolean) - Set to 'true' to bypass Docker. - **DEBUG** (string) - Set to 'testcontainers*' to enable verbose container logging. ``` -------------------------------- ### Add ElasticMQ Dependencies in Maven Source: https://github.com/softwaremill/elasticmq/blob/master/README.md Demonstrates how to add the ElasticMQ REST SQS module as a dependency in a Maven project. The artifact ID includes the Scala binary version (e.g., _2.12). ```xml org.elasticmq elasticmq-rest-sqs_2.12 ${version} ``` -------------------------------- ### Manage Queue Tags via cURL Source: https://context7.com/softwaremill/elasticmq/llms.txt Add, list, or remove tags from a queue. Tags are used for organizational purposes and cost allocation. ```bash curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=TagQueue" \ -d "Tag.1.Key=Environment" \ -d "Tag.1.Value=Production" \ -d "Tag.2.Key=Team" \ -d "Tag.2.Value=Backend" curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=ListQueueTags" curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=UntagQueue" \ -d "TagKey.1=Environment" ``` -------------------------------- ### List Dead Letter Source Queues via cURL Source: https://context7.com/softwaremill/elasticmq/llms.txt Retrieve a list of queues that are currently configured to use a specific queue as their dead letter queue. ```bash curl -X POST "http://localhost:9324/000000000000/my-dlq" \ -d "Action=ListDeadLetterSourceQueues" ``` -------------------------------- ### POST / ReceiveMessage Source: https://context7.com/softwaremill/elasticmq/llms.txt Retrieves one or more messages from the specified queue, optionally including system or message attributes. ```APIDOC ## POST /queue-url ### Description Retrieves messages from the queue. You can specify attributes to return using the AttributeName parameter. ### Method POST ### Endpoint /{accountId}/{queueName} ### Parameters #### Request Body - **Action** (string) - Required - Must be 'ReceiveMessage' - **AttributeName.n** (string) - Optional - Name of the attribute to return (e.g., 'All', 'SentTimestamp') ### Request Example curl -X POST "http://localhost:9324/000000000000/my-queue" -d "Action=ReceiveMessage" -d "AttributeName.1=All" ### Response #### Success Response (200) - **Message** (object) - Contains MessageId, ReceiptHandle, Body, and Attributes. #### Response Example ...Hello World ``` -------------------------------- ### CreateQueue API Source: https://context7.com/softwaremill/elasticmq/llms.txt API endpoints for creating queues with various attributes, including standard queues, FIFO queues, and queues with dead-letter policies. ```APIDOC ## Create Queue with Attributes ### Description Creates a new queue with specified attributes such as VisibilityTimeout, DelaySeconds, and ReceiveMessageWaitTimeSeconds. ### Method POST ### Endpoint http://localhost:9324/ ### Parameters #### Query Parameters - **Action** (string) - Required - Must be set to "CreateQueue". - **QueueName** (string) - Required - The name of the queue to create. - **Attribute.N.Name** (string) - Optional - The name of the attribute (e.g., VisibilityTimeout, DelaySeconds). - **Attribute.N.Value** (string) - Optional - The value of the attribute. ### Request Example ```bash curl -X POST "http://localhost:9324/" -d "Action=CreateQueue" -d "QueueName=my-queue" -d "Attribute.1.Name=VisibilityTimeout" -d "Attribute.1.Value=60" -d "Attribute.2.Name=DelaySeconds" -d "Attribute.2.Value=5" -d "Attribute.3.Name=ReceiveMessageWaitTimeSeconds" -d "Attribute.3.Value=20" ``` ### Response #### Success Response (200) - **QueueUrl** (string) - The URL of the created queue. #### Response Example ```xml http://localhost:9324/000000000000/my-queue 00000000-0000-0000-0000-000000000000 ``` ## Create FIFO Queue ### Description Creates a new FIFO (First-In, First-Out) queue with optional ContentBasedDeduplication enabled. ### Method POST ### Endpoint http://localhost:9324/ ### Parameters #### Query Parameters - **Action** (string) - Required - Must be set to "CreateQueue". - **QueueName** (string) - Required - The name of the FIFO queue (must end with ".fifo"). - **Attribute.1.Name** (string) - Required - Must be set to "FifoQueue" with value "true". - **Attribute.2.Name** (string) - Optional - Can be set to "ContentBasedDeduplication" with value "true". ### Request Example ```bash curl -X POST "http://localhost:9324/" -d "Action=CreateQueue" -d "QueueName=my-queue.fifo" -d "Attribute.1.Name=FifoQueue" -d "Attribute.1.Value=true" -d "Attribute.2.Name=ContentBasedDeduplication" -d "Attribute.2.Value=true" ``` ## Create Queue with Dead Letter Queue ### Description Creates a new queue and configures it to send messages that fail processing to a specified dead-letter queue. ### Method POST ### Endpoint http://localhost:9324/ ### Parameters #### Query Parameters - **Action** (string) - Required - Must be set to "CreateQueue". - **QueueName** (string) - Required - The name of the queue to create. - **Attribute.1.Name** (string) - Required - Must be set to "RedrivePolicy". - **Attribute.1.Value** (string) - Required - A JSON string specifying `deadLetterTargetArn` and `maxReceiveCount`. ### Request Example ```bash curl -X POST "http://localhost:9324/" -d "Action=CreateQueue" -d "QueueName=my-queue" -d 'Attribute.1.Name=RedrivePolicy' -d 'Attribute.1.Value={"deadLetterTargetArn":"arn:aws:sqs:us-west-2:000000000000:my-dlq","maxReceiveCount":"3"}' ``` ``` -------------------------------- ### TagQueue, UntagQueue, and ListQueueTags API Source: https://context7.com/softwaremill/elasticmq/llms.txt Add, list, and remove tags from queues for organization and cost allocation purposes. ```APIDOC ## TagQueue, UntagQueue, and ListQueueTags API ### Description Add, list, and remove tags from queues for organization and cost allocation purposes. ### Method POST ### Endpoint `http://localhost:9324//` ### Parameters #### Query Parameters - **Action** (string) - Required - `TagQueue`, `UntagQueue`, or `ListQueueTags`. - **Tag.N.Key** (string) - Optional (for `TagQueue`) - The key of the tag to add. - **Tag.N.Value** (string) - Optional (for `TagQueue`) - The value of the tag to add. - **TagKey.N** (string) - Optional (for `UntagQueue`) - The key of the tag to remove. ### Request Example ```bash # Add tags to queue curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=TagQueue" \ -d "Tag.1.Key=Environment" \ -d "Tag.1.Value=Production" \ -d "Tag.2.Key=Team" \ -d "Tag.2.Value=Backend" # List queue tags curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=ListQueueTags" # Remove tags from queue curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=UntagQueue" \ -d "TagKey.1=Environment" ``` ``` -------------------------------- ### Change Message Visibility Timeout (curl) Source: https://context7.com/softwaremill/elasticmq/llms.txt Demonstrates how to adjust the visibility timeout for a message. This can be used to extend the time a message is hidden or set it to 0 to make it immediately available again. Requires the ReceiptHandle. ```bash curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=ChangeMessageVisibility" \ -d "ReceiptHandle=abc123..." \ -d "VisibilityTimeout=120" ``` ```bash curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=ChangeMessageVisibility" \ -d "ReceiptHandle=abc123..." \ -d "VisibilityTimeout=0" ``` -------------------------------- ### ElasticMQ Dependencies (Maven) Source: https://github.com/softwaremill/elasticmq/blob/master/README.md How to add ElasticMQ SQS REST interface dependency to your Maven project. ```APIDOC ## ElasticMQ Dependencies (Maven) ### Description Add ElasticMQ SQS REST interface dependency to your Maven project. ### Code Example ```xml org.elasticmq elasticmq-rest-sqs_2.12 ${version} ``` ### Snapshot Versions To use snapshot versions, add the following repository: ``` https://oss.sonatype.org/content/repositories/snapshots/ ``` ``` -------------------------------- ### Add ElasticMQ Dependencies in SBT Source: https://github.com/softwaremill/elasticmq/blob/master/README.md Specifies how to include ElasticMQ SQS REST interface or core modules as dependencies in an SBT project. Requires defining the version and using the '%%' operator for Scala version compatibility. ```scala val elasticmqSqs = "org.elasticmq" %% "elasticmq-rest-sqs" % Version val elasticmqCore = "org.elasticmq" %% "elasticmq-core" % Version ``` -------------------------------- ### Send Batch Messages to ElasticMQ (curl) Source: https://context7.com/softwaremill/elasticmq/llms.txt Shows how to send multiple messages in a single request to an ElasticMQ queue using the SendMessageBatch API with curl. This includes sending messages with individual IDs, bodies, and optional delay settings. ```bash # Send batch of messages curl -X POST "http://localhost:9324/000000000000/my-queue" \ -d "Action=SendMessageBatch" \ -d "SendMessageBatchRequestEntry.1.Id=msg1" \ -d "SendMessageBatchRequestEntry.1.MessageBody=First%20message" \ -d "SendMessageBatchRequestEntry.2.Id=msg2" \ -d "SendMessageBatchRequestEntry.2.MessageBody=Second%20message" \ -d "SendMessageBatchRequestEntry.2.DelaySeconds=10" \ -d "SendMessageBatchRequestEntry.3.Id=msg3" \ -d "SendMessageBatchRequestEntry.3.MessageBody=Third%20message" \ -d "SendMessageBatchRequestEntry.3.MessageAttribute.1.Name=Priority" \ -d "SendMessageBatchRequestEntry.3.MessageAttribute.1.Value.DataType=Number" \ -d "SendMessageBatchRequestEntry.3.MessageAttribute.1.Value.StringValue=5" ``` -------------------------------- ### Debug Test Execution Source: https://github.com/softwaremill/elasticmq/blob/master/integration-tests/nodejs/README.md Commands to run tests with increased verbosity and debug logging for testcontainers. ```bash npm run test:verbose DEBUG=testcontainers* npm test -- --verbose --runInBand ```