In addition to our Lifecycle Support offerings, Webtide is also committed to helping develop new functionality to meet customer needs for the open source projects Webtide supports, CometD and Eclipse Jetty.
Recently Genesys, a global leader in customer experience solutions and one of Webtide’s customers, reached out regarding their usage of CometD, looking for help integrating CometD with NodeJS.
Their architecture had a browser front-end application talking to a NodeJS server application, which in turn talked to a Java CometD server application. Server-side events emitted by the CometD application needed to travel through NodeJS all the way down to the front-end, and the front-end needed a way to register interest for those events.
At the time the CometD project did not have any NodeJS integration, so Genesys partnered with Webtide to develop the integration as a sponsored effort, leveraging our knowledge as the experts behind CometD.
This resulted in two new CometD sub-projects, CometD NodeJS Client and CometD NodeJS Server, and in publishing CometD artifacts in NPM.
npm install cometd
window global object, and of the
XMLHttpRequest APIs and functionalities such as HTTP cookie handling.
XMLHttpRequest, exposes a
window global object and few other functionalities present in a browser environment such as timers (
window.setTimeout(...)) and logging (
Writing a CometD NodeJS client application is now very simple. First, install the CometD client libraries:
npm install cometd-nodejs-client npm install cometd
Second, write your application:
require('cometd-nodejs-client').adapt(); var lib = require('cometd'); var cometd = new lib.CometD(); ...
Following this framework, Genesys was able to utilize CometD from within NodeJS to talk to the Java CometD server application and vice-versa.
In the next blog we will take a look at the CometD NodeJS Server which allows the front-end application to talk to the NodeJS server application, therefore using CometD from the front-end application through NodeJS to the Java CometD server.