https://github.com/snatalenko/node-cqrs-rabbitmq
https://github.com/snatalenko/node-cqrs-rabbitmq
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/snatalenko/node-cqrs-rabbitmq
- Owner: snatalenko
- Created: 2016-12-04T21:03:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-05-27T12:53:36.000Z (about 7 years ago)
- Last Synced: 2025-01-24T15:28:01.518Z (over 1 year ago)
- Language: JavaScript
- Size: 19.5 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
RabbitMQ Message Bus for node-cqrs
==================================
## Usage
```bash
npm install bitbucket:cqrs/node-cqrs bitbucket:cqrs/node-cqrs-rabbitmq --save
```
A configured instance of RabbitMqBus must be passed in as "bus" option to the EventStore constructor:
```javascript
const EventStore = require('node-cqrs').EventStore;
const InMemoryEventStorage = require('node-cqrs').InMemoryEventStorage;
const RabbitMqBus = require('node-cqrs-rabbitmq');
const storage = new InMemoryEventStorage();
const bus = new RabbitMqBus({
connectionString: 'amqp://username:password@localhost?heartbeat=30',
queue: 'my.events',
durable: false,
appId: 'my-app-id'
});
const eventStore = new EventStore({ storage, bus });
eventStore.commit([
{ aggreateId: 1, aggregateVersion: 1, type: 'somethingHappened', payload: {} }
]);
```
The same, using DI container:
```javascript
const EventStore = require('node-cqrs').EventStore;
const InMemoryEventStorage = require('node-cqrs').InMemoryEventStorage;
const Container = require('node-cqrs').Container;
const RabbitMqBus = require('node-cqrs-rabbitmq');
const c = new Container();
c.register(InMemoryEventStorage, 'storage');
c.register(() => new RabbitMqBus({
connectionString: 'amqp://username:password@localhost?heartbeat=30',
queue: 'my.events',
durable: false,
appId: 'my-app-id'
}), 'bus');
c.register(EventStore, 'eventStore');
c.eventStore.commit([
{ aggreateId: 1, aggregateVersion: 1, type: 'somethingHappened', payload: {} }
]);
```
### Constructor Options
- connectionString
- queue
- queuePrefix
- durable
- prefetch
- appId