1.0.8 • Published 2 years ago

@rfcx/message-queue v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

A simple wrapper on top of message queues.

Usage example for SQS

import { MessageQueue } from '@rfcx/message-queue'

const options = {
  ...
}
const messageQueue = new MessageQueue('sqs', options)

messageQueue.publish('publication-queue', { foo: 'bar' })

messageQueue.subscribe('subscription-queue', (message: unknown) => {
  return true
})

Usage example for SNS

import { MessageQueue } from '@rfcx/message-queue'

const options = {
  ...
}
const messageQueue = new MessageQueue('sns', options)

messageQueue.publish('publication-topic', { foo: 'bar' })

API

new MessageQueue(type, options)

Creates a new MessageQueue client.

Options

  • type - String - client type (sqs or sns)
  • options - Object - additional options
  • options.topicPrefix - String - SQS queue or SNS topic prefix (e.g. staging in staging-event-created)
  • options.topicPostfix - String - SQS queue or SNS topic postfix (e.g. staging in event-created-staging)

Environmental variables

For SQS client: AWS_ACCESS_KEY_ID, AWS_SECRET_KEY, AWS_REGION_ID

For SNS client: AWS_ACCESS_KEY_ID, AWS_SECRET_KEY, AWS_REGION_ID, AWS_ACCOUNT_ID

MESSAGE_QUEUE_ENDPOINT if you want to use custom endpoint

Additional notes

  • Note that SNS client does not have subscribe method as you can't subscribe directly to SNS topic.

Publishing

Publishing to NPM registry is done automatically via GitHub Actions once new release is published in the GitHub repository. You must have NPM_PUBLISH_TOKEN secret to be defined in your repository or organization. Reference this or this for instructions.

1.0.8

2 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago