feat(local-elasticmq): Add ElasticMQ-backed local queue emulator#57
Open
mnzsss wants to merge 7 commits into
Open
feat(local-elasticmq): Add ElasticMQ-backed local queue emulator#57mnzsss wants to merge 7 commits into
mnzsss wants to merge 7 commits into
Conversation
Move processQueueMessage from @ez4/local-queue into @ez4/local-common so both in-memory and ElasticMQ emulators can use the same dispatch lifecycle. Rename from processLambdaMessage to processQueueMessage and keep local-queue compatibility via re-export.
…pport Replace direct in-memory registration with registerQueueEmulator wrapper that checks for external clients via emulator:getClient trigger. Falls back to in-memory mode when no external provider is registered.
New provider package that integrates with @ez4/local-queue via emulator triggers to provide SQS-compatible local queue emulation using ElasticMQ. Includes: - SQS SDK client factory with send/receive message support - Queue topology management (standard, FIFO, DLQ, purge) - Poller lifecycle with subscriber dispatch - Local and test options resolution with config validation - Unit tests covering options, client, topology, and poller
Example project demonstrating ElasticMQ-backed local queue emulation with standard, FIFO, and deduplication FIFO queue configurations.
Add elasticmq-native service to docker-compose, register @ez4/local-elasticmq workspace in root package.json, and document emulator modes in local-queue README.
The local-queue emulator now returns null instead of creating a default queue client when no external client is available. The ElasticMQ emulator registers an 'emulator:getClient' handler to provide its own client and passes the real service context through instead of a mock.
5f4e960 to
b25a1c4
Compare
local-elasticmq was pinned at 0.47.0 with ^0.47.0 ez4 deps while the rest of the monorepo is 0.48.0. Since ^0.47.0 does not satisfy 0.48.0, npm installed the published @ez4/local-common@0.47.0 (predating processQueueMessage) instead of symlinking the workspace, breaking the CI build. Bump version and deps to 0.48.0 so the workspace resolves.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new
@ez4/local-elasticmqprovider that lets the local queue emulator run on top of ElasticMQ instead of the in-memory implementation. It also refactors@ez4/local-queueso the emulator can plug in an external client through a trigger, keeping the in-memory mode as the default fallback.The new package is opt-in: install it next to
@ez4/local-queueand local queues talk to a real SQS-compatible service. Don't install it and nothing changes — the in-memory emulator keeps working exactly as before.Why
The in-memory emulator is great for fast tests but it diverges from how SQS actually behaves. FIFO ordering, deduplication windows, visibility timeouts, DLQ redrive — those are easy to get subtly wrong when the local implementation doesn't share the same semantics as the deployed one.
ElasticMQ ships a real SQS-compatible queue server, so pointing the emulator at it removes that gap. Local development and CI exercise the same wire protocol, the same FIFO/dedup rules, and the same client SDK the AWS provider uses in production. Bugs that only show up against real SQS now also show up locally.
The change is structured so adopting ElasticMQ stays a choice. Projects that don't need SQS-level fidelity keep the zero-setup in-memory mode. Projects that do install one extra package and add a couple of lines of
localOptions.What changed
@ez4/local-elasticmq(new package)localOptions.queue(host/port/endpoint)emulator:getClientandemulator:getServicestriggers so@ez4/local-queuepicks it up automatically when present@ez4/local-queueregisterQueueEmulator, which first asks for an external client via theemulator:getClienttrigger and falls back to in-memory when none is registeredprocessQueueMessage, formerlyprocessLambdaMessage) into@ez4/local-commonso both emulators reuse it@ez4/local-queuefor backwards compatibility@ez4/local-commonprocessQueueMessagehandler (begin/ready/done/error/end lifecycle, validation, scoped runtime)Examples and infra
examples/hello-local-elasticmq: standard, FIFO, and FIFO-with-deduplication queue configurations against the ElasticMQ emulatordocker-compose.yml: add thesoftwaremill/elasticmq-nativeservice on port9324@ez4/local-elasticmqin the root workspaceBehavior
Before:
After:
@ez4/local-queuekeeps the in-memory emulator as default@ez4/local-elasticmqand configuringlocalOptions.queueswitches local queues to ElasticMQ transparently