@hindawi/queue-service
v1.4.0
Published
Hindawi queue service package.
Downloads
29
Readme
Message Queue Service
This service adds the ability to connect to a SQS message queue, consume messages and publish messages to SNS
It is best used if you employ a SNS/SQS setup for interservice communication
API
createQueueService()
- creates an instance of the messageQueueServiceservice.publishMessage(message)
- publishes a message to the configure SNS topic.
The message should be of type{event: String, data: Any, timestamp?: Date.toISOString, messageAttributes?: Object}
service.registerListener({event: String, handler: Function})
- registers a handler function for the specified event.
You can register multiple handlers for each event. To do this, you can call this function multiple times with the sameevent
value
The service will call all handlers registered for theevent
value found in the messageservice.startListening()
- starts listening on the specified queue
Required Env vars
NODE_ENV=development
AWS_SNS_SQS_REGION=us-east-1
AWS_SNS_SQS_ACCESS_KEY=****
AWS_SNS_SQS_SECRET_KEY=****
AWS_SQS_ENDPOINT=http://localhost:4566
AWS_SNS_ENDPOINT=http://localhost:4566
AWS_SNS_TOPIC=test1
AWS_SQS_QUEUE_NAME=screening-queue
Usage
If you want to use it in an xpub
app, you can find an
example here.
Check this documentation for an example of how you can configure a SNS/SQS clone service to run locally in docker.