SimpleMule
Simple Mule-like implementation for Node.js
Installation
Via npm on Node:
npm install simplemule
Usage
Reference in your program:
var sm = ;
You can define components and connect them. A component needs a function that receives a context
and a message
.
var component = sm;
You can send a message to a component:
component;
It is processed immediatly.
You can post a message to a component:
component;
It is processed after attending any pending callbacks in Node.js. Internally, it use setImmediate
.
But in general, you don't send message directly to a component. Usually, you connect them:
var hello = sm; hello;hello;// hello.post("world");
context.send
or context.post
first parameter is the name of the channel, and the second parameter is the message.
component.connect
first parameter is the name of the output channel, and the second parameter is the component
that listen on that channel.
You can use the default channel, ommitting the name:
var hello = sm; hello;hello;// hello.post("world");
You can connect more than one component to the same output channel:
component;component;
or to the default channel:
component;component;
Usually, after building the topology of components, you start the play sending one or more message to one or more starter components:
starter;queuereader;listener;
Development
git clone git://github.com/ajlopez/SimpleMule.git
cd SimpleMule
npm install
npm test
Samples
TBD
Versions
- 0.0.1: Published
Inception
Years ago (+- 8 years) I gave a talk about ESB (Enterprise Service Bus) demoing Mule:
That old version was a simple console application, with an ugly XML configuration file. Now, it has lot of functionality (check the above links). I think it is time to write a simple version for Node.js. Instead of Mule connectors, this version has components: arbitrary functions that receive and send/post message to other components.
Related projects:
Contribution
Feel free to file issues and submit pull requests � contributions are welcome.
If you submit a pull request, please be sure to add or update corresponding
test cases, and ensure that npm test
continues to pass.