What is Chorus.js?

Chorus.js offers a very simple way to orchestrate asynchronous and synchronous APIs in Node applications.

Our focus is on making chorus.js super easy to learn and use everywhere, from an entry-level Raspberry Pi to the most scalable PaaS, and anything in between.

What problems does Chorus.js solves?

Long running (a.k.a. stateful) orchestrations are an integral part of any application whether they manage content, support tickets or mortgages.

Today, developers code these long running orchestrations in a bespoke way because there is simply no support for it in programming languages, patterns or query languages. They are notoriously difficult to conceptualize, code, debug and especially maintain. The problem is even more acute in composite systems where a lot of time is wasted trying to align the behavior of several orchestrations.

Chorus.js is introducing a new orchestration language, Cord, simple to learn and use and which makes state a primary concept of application architecture. With Cord we aim at tackling all the barriers that limited the adoption of orchestration languages in the past and help developers write stateful code. 

Light weight and integrated vs big and clunky Orchestration engines have always been built as big and clunky pieces of middleware (typically running BPEL). Each time an app needed to invoke some stateful code it would pass control to some BPEL code. Yep, we agree, not really practical.
Versioning, versioning, versioning Versioning is never easy, but it’s particularly hard when state is involved because of inflight orchestration instances. Chorus.js takes a no nonsense approach to decouple the business logic from the way it stores state such that new orchestration definitions can operate on existing instances.
Initiate instances in any state When a new orchestration definition is created, there is often the need to create instances in an arbitrary state (Data Migration). Chorus.js’ architecture greatly simplifies the problem of migrating existing instances to a particular API orchestration definition, even when it is the first time this orchestration definition is deployed.
Easy to learn Orchestration languages like BPEL are not necessarily that hard to learn, the concepts are pretty straightforward, but visual editors are horrific. Chorus.js offers a simple syntax that everyone can master in minutes and allows you to “code” your orchestration.
Easy to deploy With Chorus.js, every API/Service orchestration is a simple node app that you can deploy separately when it makes sense or import in your own app.
Free, Open Source Software Unlike most BPEL engines, Chorus is free to use and open source (Apache 2.0 license).

How does Chorus.js works?

Traditional (BPEL-based) Service Orchestration Engines are operated centrally independent of any app and using their own data store. This architecture introduces four core problems:



  1. The app and the orchestration business logic are too decoupled
  2. The app cannot easily access the orchestration instance data, the instance cannot easily access the app data
  3. a BPEL engine requires a different set of skills and operational procedures
  4. All definitions and instances run off the same engine, regardless of the app they relate too

With Chorus.js, “Chorus Orchestration Definitions” (aka CORDs) are deployed within your Node.js app. All orchestration definitions are actually self-standing and independent of one another. A CORD can even share the same MongoDB store as your application if it makes sense architecturally. CORDs can be called directly from the app and CORDs can call the app’s API or any 3rd party service.



Creating and deploying a Chorus Orchestration Definition (CORD) is as simple as 1-2-3…

Step 1: Create a CORD

For instance, here is a simple CORD which calculates the area of a rectangle, calculate-area-cord-diagram Step 2: Chorus.js development tool generates the corresponding Node application in real-time

var express = require('express');
var app = express();
var http = require('http'),
    https = require('https'),
    bodyParser = require('body-parser');
    validator = require('validator');

var services = require('./services');

var chorus = 'chorus' ;


var databaseUrl = chorus ; // "username:password@example.com/mydb"
var collections = ["instances"]
var mongojs = require('mongojs');
var db = mongojs.connect(databaseUrl, collections);

var log4js = require('log4js');

  appenders: [
    { type: 'console' },
    { type: 'file', filename: 'logs/'+chorus+'.log', maxLogSize:20480, backups:3, category: chorus }

var logger = log4js.getLogger();

var pr = express.Router();
app.use('/'+chorus+'/calculateArea', pr);

var sr = services.ServiceRouter() ;
app.use('/services', sr);

//activity paths
var processName = 'calculateArea' ;
var processVersion = 'v1' ;
var invoke_calculateArea_multiply = '/'+processName+'/'+processVersion+'/invoke/multiply' ;
var receive_calculateArea_calculateRectangleArea = '/'+processName+'/'+processVersion+'/init' ;


Step 3: Start the application

test@chorusjs:/home/chorus/samples/calculatearea# npm install
test@chorusjs:/home/chorus/samples/calculatearea# node calculateArea_v1.js


[2014-05-25 00:44:45.681] [WARN] [default] - [ENDPOINT] calculateArea_calculateRectangleArea_receive
[2014-05-25 00:44:45.685] [WARN] [default] - [ENDPOINT] calculateArea_calculateArea_invoke
[2014-05-25 00:44:45.692] [WARN] [default] - [SERVER] listening on port 3000

That’s it, that’s all it takes to build and deploy a cord. If you want to learn more about Chorus.js, you can check our samples and the getting started guide.

Leave a Reply