1.0.22 • Published 4 years ago
msek-rabbitmq-lib v1.0.22
⚡️ 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
4 years ago
1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.22
4 years ago
1.0.21
4 years ago
1.0.20
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.12
4 years ago
1.0.11
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.10
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago