CXCloud Process Engine Core
A simple helper for using multiple AWS SQS queues at the same time. This tool
provides an easy way to map incoming events to actions.
Installation and Usage
npm install @cxcloud/process-engine-core
import {
createQueueProcessor,
createQueuePool
} from '@cxcloud/process-engine-core';
const pool = createQueuePool([
createQueueProcessor(
{
name: 'my-sqs-queue',
concurrency: 2
},
[
{
conditions: [
{
path: 'myEvent.name',
value: 'someValue'
},
{
path: 'customer.type',
value: 'gold'
}
],
action: (message, sendMessage) => {
console.log('Received Message:', message.data);
message.deleteMessage().then(() => {
message.next();
});
}
}
],
message => {
console.error('No processor found');
message.next();
}
),
createQueueProcessor(),
createQueueProcessor()
]);
pool.start();
Documentation
createQueuePool(processors: QueueProcessor[]) ⇒ QueuePool
This function creates a queue pool that can be started at the same time and
queried to access each item.
The resulting QueuePool
instance has the following methods:
start()
— Start all the queue processor instancesfindByName(name: String) ⇒ QueueProcessor
— Find a queue processor instance
by it's name
createQueueProcessor(options, actionMap, fallbackFn) ⇒ QueueProcessor