Change Streams

You can use the MongoDB change steams API to watch for real time changes to your tables and collections.

The HCL OneDB™ wire listener supports the MongoDB change streams API which allows MongoDB clients to subscribe to all data changes in a collection or relational table on the HCL OneDB database server. This support is based on the JDBC Smart Trigger support for the database's push data feature.

With the wire listener, you must open a change stream on each individual table or collection that you want to subscribe to. The wire listener does not support watching an entire database or the entire system from a single change stream.

HCL OneDB generates the following change stream events:
  • insert
  • update
  • delete

For update change stream events, unlike MongoDB, the wire listener always returns the full document as part of the update event. Replace change stream events are not generated by HCL OneDB. Any replace operation run against HCL OneDB through a MongoDB client will result in a change stream event of type update.

HCL OneDB also does not generate drop, rename, or dropDatabase change stream events. You cannot drop or rename a table that is being watched by a smart trigger, nor can you drop the database that contains it.

The wire listener allows you to filter which change stream events you are subscribed to. You can filter by the change stream operation type ("insert, "update", and/or "delete") or by matching against one or more fields in the full document. Filters are set by providing a pipeline when calling the MongoDB API's watch function. The wire listener only supports $match stages in the pipeline. You can provide a $match stage to filter on the operationType field of the change stream event. You an also provide a $match stage to filter on one or more fields in the fullDocument field of the change stream event.

The wire listener does not support resuming a change stream. Resume tokens are included in change stream events to indicate the log id and position associated with the change stream event. But the tokens cannot be used to resume a change stream from a particular event.