# msek-rabbitmq-lib

> ## How to use?

Latest version **1.0.22** (published 2021-11-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install msek-rabbitmq-lib
pnpm add msek-rabbitmq-lib
yarn add msek-rabbitmq-lib
bun add msek-rabbitmq-lib
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.22 |
| Published | 2021-11-14 |
| First published | 2021-09-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 28.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Moustafa Kotb |
| Maintainers | msafwat |

## Links

- npm: https://www.npmjs.com/package/msek-rabbitmq-lib
- npm.io page: https://npm.io/package/msek-rabbitmq-lib

## Dependencies (2)

- [uuidv4](https://npm.io/package/uuidv4.md) 6.2.12
- [amqplib](https://npm.io/package/amqplib.md) 0.8.0

## Recent versions

- 1.0.22 (latest) — 2021-11-14
- 1.0.21 — 2021-11-14
- 1.0.20 — 2021-11-14
- 1.0.19 — 2021-11-14
- 1.0.18 — 2021-11-14
- 1.0.17 — 2021-11-14
- 1.0.16 — 2021-11-14
- 1.0.15 — 2021-11-14
- 1.0.14 — 2021-11-14
- 1.0.13 — 2021-11-14
- 1.0.12 — 2021-11-14
- 1.0.11 — 2021-11-01
- 1.0.10 — 2021-10-23
- 1.0.9 — 2021-10-15
- 1.0.8 — 2021-10-15
- … 8 more at https://npm.io/package/msek-rabbitmq-lib/versions

## README

# ⚡️ MSEK - Rabbitmq Library

## How to use?

Run 'npm i msek-rabbitmq-lib' in your Microservice.

Set environment variable 'SERVICE_NAME'. for an example SERVICE_NAME=msek-accounting-service.
Set environment variable 'RABBITMQ_URL'. or it will be 'amqp://localhost' by default.

import 
```typescript
import DomainEvent, {MsekRabbitmq} from 'msek-rabbitmq-lib';

export default class AccountActivatedEvent extends DomainEvent {
    constructor(account: Account) {
        super(
            account.AccountingSystemId.getMerchantCode(),   // userId
            account.Id.RawId,                               // aggregateId
            'account',                                      // aggregateType
            'account.activated',                            // eventName
            {                                               // context
                accountId: account.Id.RawId,
                externalId: account.ExternalId,
                name: account.Name,
                balance: account.Balance.Amount,
                currency: account.Balance.Currency,
                accountingSystemId: account.AccountingSystemId.RawId
            });
    }
}

// Publish domain event
const published = await MsekRabbitmq.rabbitmq.publish(eventName, domainEvent);

// Register consumer in bootstrap
private async registerConsumers() {
    await MsekRabbitmq.rabbitmq.consume(eventName, async (message: any) => {
    });
}
```

Note: You may need to install the amqplib types if you using typescript 'npm i --save-dev @types/amqplib'.

---
_Source: https://npm.io/package/msek-rabbitmq-lib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
