How do we Identify multiple subscription notifications are from same transaction

Hi,

We have different namespaces loaded into cdb and each namespace is from different component in the application. Each namespace has one subscriber and getting notifications whenever there is a config change. We have a use case in which different namespace configs are pushed in a single netconf transaction and we need a way to identify whether the cdb notifications are from same transaction or different for internal verification.
Can you please help us on this.

Thanks,
-Venkat

cdb_get_txid() will read the last transaction id. The id is guaranteed to be unique. See the confd_lib_cdb(3) man page for details.

Example pseudo code that you can place in your CDB subscriber after your call to cdb_read_subscription_socket():

int rsock;
rsock = socket(PF_INET, SOCK_STREAM, 0));
cdb_connect(rsock, CDB_DATA_SOCKET, (struct sockaddr*)addr, sizeof (struct sockaddr_in));
cdb_start_session2(rsock, CDB_RUNNING, CDB_LOCK_REQUEST);

struct cdb_txid txid;
cdb_get_txid(rsock, &txid);
printf("TRANSACTION ID: %d-%d-%d\n", txid.s1, txid.s2, txid.s3);
cdb_close(rsock);

Will print something like:
TRANSACTION ID: 1567-238190-391096

To verify from the the transaction id from for example the CLI:

# show confd-state internal cdb datastore transaction-id 
NAME         TRANSACTION ID      
---------------------------------
running      1567-238190-391096

Thank you for pseudo code. It works for me.
But, can we get transactionId without opening new cdb session with subscription notification?

You cannot make a cdb_get_txid() call over the subscription socket. You need a data socket for that CDB API call. What is your concern regarding doing so?

Without knowing your use case in detail here, an alternative could be to use cdb_read_subscription_socket2() when reading the subscription notification and when the CDB_SUB_FLAG_IS_LAST flag is set you increment a counter that you share between your applications. See confd_lib_cdb(3) man page for details on the CDB_SUB_FLAG_IS_LAST flag.