Add support for identifying the id of the transaction which spawned the

message, as requested (https://github.com/oracle/odpi/issues/32).
This commit is contained in:
Anthony Tuininga 2017-11-08 10:18:18 -08:00
parent 26c3a4c243
commit c122690ac4
4 changed files with 16 additions and 1 deletions

View File

@ -96,6 +96,12 @@ Message Objects
the notification.
.. attribute:: Message.txid
This read-only attribute returns the id of the transaction that generated
the notification.
.. attribute:: Message.queries
This read-only attribute returns a list of message query objects that give

2
odpi

@ -1 +1 @@
Subproject commit 6ad9d4a9cc11bfdb7246a87b8e4a1c289f264d41
Subproject commit d71b3224582bcf80b804c7bbb2e7c25ac9b94fb6

View File

@ -34,6 +34,7 @@ def callback(message):
registered = False
return
print("Message database name:", message.dbname)
print("Message tranasction id:", message.txid)
print("Message queries:")
for query in message.queries:
print("--> Query ID:", query.id)

View File

@ -34,6 +34,7 @@ typedef struct {
udt_Subscription *subscription;
dpiEventType type;
PyObject *dbname;
PyObject *txId;
PyObject *tables;
PyObject *queries;
} udt_Message;
@ -92,6 +93,7 @@ static PyMemberDef g_MessageTypeMembers[] = {
READONLY },
{ "type", T_INT, offsetof(udt_Message, type), READONLY },
{ "dbname", T_OBJECT, offsetof(udt_Message, dbname), READONLY },
{ "txid", T_OBJECT, offsetof(udt_Message, txId), READONLY },
{ "tables", T_OBJECT, offsetof(udt_Message, tables), READONLY },
{ "queries", T_OBJECT, offsetof(udt_Message, queries), READONLY },
{ NULL }
@ -450,6 +452,12 @@ static int Message_Initialize(udt_Message *self,
message->dbNameLength, encoding);
if (!self->dbname)
return -1;
if (message->txId) {
self->txId = PyBytes_FromStringAndSize(message->txId,
message->txIdLength);
if (!self->txId)
return -1;
}
switch (message->eventType) {
case DPI_EVENT_OBJCHANGE:
self->tables = PyList_New(message->numTables);