1.0.22 • Published 2 years ago

msek-rabbitmq-lib v1.0.22

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

⚡️ 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

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'.

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.10

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