eip
Enterprise Integration Patterns for javascript.
This repo is based on jkanschik/node-eip implements various eip patterns for javascript and mainly enhances the aggregator functionality.
Installation
npm install --save eip
Usage
Create a Route
const eip = ;const route = 'Route-0' route: retryLimit: 3 retryDelay: 1000 isErrorRoute:false
Add a processor to the Route
route
Inject events to Route
route;// output: [2017-03-10 17:04:12.636] [INFO] [aggregator-eip] - [Route-0(info-1)] 2route;// output: [2017-03-10 17:04:13.082] [INFO] [aggregator-eip] - [Route-0(info-1)] 4
Builtin Processors
// or// Timer, Store and AggregationStrategy are abstract classes exported by eip that can be extended.// see eip-mongo and eip-rabbit for implementations of Timer on top of rabbitmq and Store on top of mongo ; // or // filter can accept conditions tha return a promiseprocess event event // custom processor that transforms the eventprocess // transform event returning a promise // 10 events per second (1000 ms) //or// Timer, PubSub and Queue are abstract classes exported by eip that can be extended.// see eip-redis and eip-rabbit for implementations of Timer on top of rabbitmq and pubSub and queue on top of redis //logging // all logger scan transform the logging msg using a callback// eg: 'message to be logged:' + event;
Aggregator example
const aggregator = ; aggregator; aggregator; aggregator; // it will be aggregated and log to output:// [2017-03-10 16:32:07.605] [INFO] [aggregator-eip] - [Route-1(info-1)] {"body":["one","two","three"],"headers":{"status":"COMPLETED","id":"the id to aggregate data","param":"two","anotherParam":"other","aggregationNum":1,"timeoutNum":0,"previousStatus":"INITIAL"}}// [2017-03-10 16:32:08.606] [DEBUG] [aggregator-eip] - [Route-1(aggregate-0)] [timeout-1] [1] Already completed // we could have formatted the output using:aggregator;/*[2017-03-10 16:38:05.484] [INFO] [aggregator-eip] - [Route-1(info-2)] { "body": [ "one", "two", "three" ], "headers": { "status": "COMPLETED", "id": "the id to aggregate data", "param": "two", "anotherParam": "other", "aggregationNum": 1, "timeoutNum": 0, "previousStatus": "INITIAL" }}[2017-03-10 16:38:06.152] [DEBUG] [aggregator-eip] - [Route-1(aggregate-0)] [timeout-1] [the id to aggregate data] Already completed*/
License
MIT