Mule-like components processing arbitrary messages


Simple Mule-like implementation for Node.js

Via npm on Node:

npm install simplemule

Reference in your program:

var sm = require('simplemule');

You can define components and connect them. A component needs a function that receives a context and a message.

var component = sm.createComponent(function (contextmessage) {

You can send a message to a component:

component.send("Hello, world");

It is processed immediatly.

You can post a message to a component:"Hello, world");

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.createComponent(function (contextmessage) {
    context.send('next', "Hello, " + message);
    //'next', "Hello, " + message); 
hello.connect('next', component);

context.send or 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.createComponent(function (contextmessage) {
    context.send("Hello, " + message);
    //"Hello, " + message); 

You can connect more than one component to the same output channel:

component.connect('next', component1);
component.connect('next', component2);

or to the default channel:


Usually, after building the topology of components, you start the play sending one or more message to one or more starter components:

git clone git://
cd SimpleMule
npm install
npm test


  • 0.0.1: Published

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:

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.