Realtime Push with MarkLogic and Node.js via Websockets

MarkLogic has an awesome alerting feature that enables you to trigger an event when new or updated database content matches certain criteria. Once a rule’s criteria is met, an action is triggered that executes an arbitrary XQuery module. You can send an email, an SMS message, perhaps place a phone call with the Twillio API, modify other content in the database, whatever your heart desires. But what if you want to deliver realtime notifications to a user in a browser?

Enter Websockets! Websockets is part of (well, was part of) the HTML5 initiative and defines a full-duplex single socket connection over which messages can be sent between client and server. Though MarkLogic and XQuery doesn’t support persistent connections such as websockets, it’s relatively easy to pair it with a 3rd party websocket capable server like Node.js with a library like node-websocket-server.

By pairing MarkLogic’s alerting feature with Node.js and websockets you can push realtime notifications to connected clients in Websockets capable browsers, mobile devices, etc.

Have a look…



About Mike Brevoort

Enterprise Web Practice Manager - @mbrevoort on Twitter

Leave a Comment

*