With the advent of micro services architecture and DevOps model, enterprise architects expect database servers to operate in real-time environment, push data and events to clients rather than clients polling for data, scale linearly, enable zero downtime deployments, and easy integration with other middleware services like enterprise message bus.
“Push data to client” functionality is designed to help enterprise data architects seamlessly integrate HCL Informix database server with applications built using micro services architecture. This new functionality allows developers create applications using event driven programming model against real-time data changes in the HCL Informix databases. Applications will be able to register callback functions on interested dataset and let the database driver invoke callback APIs along with the data being changed in developer friendly JSON format.
Smart trigger functionality in HCL Informix JDBC driver is one such implementation using “push data to client” functionality.
One of the key aspects of “push data to client” functionality is its ability to scale linearly as more and more event conditions are registered with the database server. Linear scalability is achieved using thin client architecture where majority of the work is done by the server.
This functionality does not interfere with clients performing changes to HCL Informix database. HCL Informix log capture thread asynchronously reads the logical log records, feed the log records to a ‘grouper’ fan-out thread whose job is to maintain transaction order, and distribute the log records to a number of configurable worker threads. The worker threads apply smart trigger event WHERE clause filter on these log records, construct JSON documents for event data, and push out JSON documents to client applications.
This parallel architecture can serve any number of smart trigger event conditions without degrading the application performance.
Make sure the storage pool is configured. This is a onetime operation:
In order to register smart trigger event conditions with HCL Informix server, the application user will need replication permission on sysadmin database. This is a onetime operation.
Grant replication permission on sysadmin database:
In the client application, register with the server as a push data application. This is a onetime operation for each instance of the client application.
* This command registers client as a push-data session, and returns unique session id. This session id is needed for reading event documents using the read api.
Register session specific attributes like “timeout” and maximum number of event records returned to the client from a single read call:
Register one or more push data event conditions:
Please refer to the HCL Informix Knowledge center for the list of input JSON document attributes.
Read event documents using HCLInformix smartblob API:
Client shall need to invoke smartblob read api to read event data. Input for the smartblob read api includes:
ESQLC read API Example:
Deregister one or more event conditions for a given table:
Deregister all event conditions with the same “label” attribute tag:
Sample Output for Event Documents
Sample output document for Insert operation:
Sample output document for Update operation:
Sample output document for Delete operation:
Sample output for document related to timeout condition:
Sample output document related to error condition:
Sample output for warning document:
This document is returned when event documents were discarded due to maximum threshold for pending documents to be consumed by the client.
Please refer to HCL Informix Knowledge center for the description of output JSON document attributes.
ESQL/C Demo Application for Push Data to Client Functionality
Please refer to $INFORMIXDIR/demo/cdc/pushdata.ec for sample implementation using ESQL/C.
Sample ESQL/C code:
The above sample code demonstrates the low level interface for client applications working with “push data to client” functionality. Smart trigger functionality in HCL Informix JDBC driver hides all the complexity involved with using these low-level server API calls, and provides a simpler interface for Java developers.
“Push data to client” functionality in HCL Informix server along with the Smart trigger functionality in HCL Informix JDBC driver simplifies application development, and offers rich functionality to seamlessly integrate HCL Informix database server with other middleware services in a micro services based enterprise architecture.
Connect with me on LinkedIn
Informix is a trademark of IBM Corporation in at least one jurisdiction and is used under license.