# @cats-cradle/message-broker

> An API for publishing and receiving async messages

Latest version **1.0.0** (published 2023-03-12) · 0 weekly downloads

## Install

```sh
npm install @cats-cradle/message-broker
pnpm add @cats-cradle/message-broker
yarn add @cats-cradle/message-broker
bun add @cats-cradle/message-broker
```

Provides the command `app`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-03-12 |
| First published | 2023-03-12 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 29 |
| Unpacked size | 158.8 KB |
| Known vulnerabilities | 0 (+13 in 7 direct dependencies) |
| Install scripts | no |
| Maintainers | hxtree |

## Links

- npm: https://www.npmjs.com/package/@cats-cradle/message-broker
- npm.io page: https://npm.io/package/@cats-cradle/message-broker

## Dependencies (29)

- [rxjs](https://npm.io/package/rxjs.md) 7.5.6
- [uuid](https://npm.io/package/uuid.md) ~9.0.0
- [lodash](https://npm.io/package/lodash.md) ~4.17.21
- [express](https://npm.io/package/express.md) 4.18.2
- [mongoose](https://npm.io/package/mongoose.md) ~6.9.1
- [aws-lambda](https://npm.io/package/aws-lambda.md) 1.0.7
- [handlebars](https://npm.io/package/handlebars.md) ~4.7.7
- [node-cache](https://npm.io/package/node-cache.md) 5.1.2
- [@nestjs/core](https://npm.io/package/@nestjs/core.md) 9.2.1
- [html-to-text](https://npm.io/package/html-to-text.md) ~9.0.4
- [@nestjs/common](https://npm.io/package/@nestjs/common.md) 9.2.1
- [@nestjs/config](https://npm.io/package/@nestjs/config.md) 2.2.0
- [@nestjs/swagger](https://npm.io/package/@nestjs/swagger.md) ~6.1.3
- [class-validator](https://npm.io/package/class-validator.md) 0.13.2
- [@nestjs/mongoose](https://npm.io/package/@nestjs/mongoose.md) 9.2.1
- [@nestjs/terminus](https://npm.io/package/@nestjs/terminus.md) 9.1.1
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) 0.1.13
- [class-transformer](https://npm.io/package/class-transformer.md) 0.5.1
- [@aws-sdk/client-s3](https://npm.io/package/@aws-sdk/client-s3.md) ~3.287.0
- [source-map-support](https://npm.io/package/source-map-support.md) ~0.5.21
- [@aws-sdk/client-ses](https://npm.io/package/@aws-sdk/client-ses.md) ~3.279.0
- [aws-sdk-client-mock](https://npm.io/package/aws-sdk-client-mock.md) ~2.1.0
- [aws-serverless-express](https://npm.io/package/aws-serverless-express.md) ~3.4.0
- [@cats-cradle/constructs](https://npm.io/package/@cats-cradle/constructs.md) 0.0.1
- [@cats-cradle/base-nodejs](https://npm.io/package/@cats-cradle/base-nodejs.md) 1.0.2
- [@nestjs/platform-express](https://npm.io/package/@nestjs/platform-express.md) 9.3.9
- [@vendia/serverless-express](https://npm.io/package/@vendia/serverless-express.md) 4.8.2
- [@cats-cradle/nestjs-modules](https://npm.io/package/@cats-cradle/nestjs-modules.md) 0.2.0
- [@cats-cradle/validation-schemas](https://npm.io/package/@cats-cradle/validation-schemas.md) 0.2.2

## Recent versions

- 1.0.0 (latest) — 2023-03-12

## README

# @cats-cradle/message-broker

This is a “Pub/Sub Message Broker”. It enables async communication between
microservices to provide loosely coupling.

- SNS topics are deployed with the message broker.
- SQS deployments should be owned by consumer.

## Message Categories

**Command** Command send a idempotent request to a topic asking subscribers to
perform task. The consumer of a command does not inform provide a response to
the publisher. The publisher does expect something to occur as a result of the
request.

> Publisher -> SNS -> SQS -> Consumer

**Event** Publish to a SNS topic informing any subscribers that something
occurred within a given system. Events published may be significant events that
were published only for the purpose of data retention and analytic purposes.

> Publisher -> SNS -> SQS -> Consumer

**Request** Publish an async message to a single queue letting them know which
queue to send a reply to.

> Publisher -> SQS -> Consumer -> (SQS -> Publisher)

**Reply** In response to a request publish an message to a single queue as
request.

> (Publisher -> SQS) -> Consumer -> SQS -> Publisher

## TODO

- Add a feature to make it easy for apps to publish to events.
- Add a feature to make it easy to subscribe to events.
- Provision S3 bucket and place all history of all events into.
- Save all messages received to bucket.
- Indicate whether message was sent only for testing / debugging purposes and
  should not contaminate history.
- Hydration that ties into api-client query might be nifty.
- logical id format
- decouple topics from broker into global lib

## Documentation

- <https://medium.com/design-microservices-architecture-with-patterns/microservices-asynchronous-message-based-communication-6643bee06123>
- <https://badia-kharroubi.gitbooks.io/microservices-architecture/content/patterns/communication-patterns/message-queue-pattern.html>
- <https://aws.plainenglish.io/an-introduction-to-request-reply-pattern-and-its-uses-2a0bb74ff7d8>

---
_Source: https://npm.io/package/@cats-cradle/message-broker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
