Added support for indicating if the subscription is still registered with the
database when a notification is received.
This commit is contained in:
parent
7b9ce90842
commit
980f3d491c
@ -107,6 +107,16 @@ Message Objects
|
||||
to the callback procedure specified when a subscription is created.
|
||||
|
||||
|
||||
.. attribute:: Message.consumerName
|
||||
|
||||
This read-only attribute returns the name of the consumer which generated
|
||||
the notification. It will be populated if the subscription was created with
|
||||
the namespace :data:`cx_Oracle.SUBSCR_NAMESPACE_AQ` and the queue is a
|
||||
multiple consumer queue.
|
||||
|
||||
.. versionadded:: 6.4
|
||||
|
||||
|
||||
.. attribute:: Message.dbname
|
||||
|
||||
This read-only attribute returns the name of the database that generated
|
||||
@ -130,12 +140,13 @@ Message Objects
|
||||
.. versionadded:: 6.4
|
||||
|
||||
|
||||
.. attribute:: Message.consumerName
|
||||
.. attribute:: Message.registered
|
||||
|
||||
This read-only attribute returns the name of the consumer which generated
|
||||
the notification. It will be populated if the subscription was created with
|
||||
the namespace :data:`cx_Oracle.SUBSCR_NAMESPACE_AQ` and the queue is a
|
||||
multiple consumer queue.
|
||||
This read-only attribute returns whether the subscription which generated
|
||||
this notification is still registered with the database. The subscription
|
||||
is automatically deregistered with the database when the subscription
|
||||
timeout value is reached or when the first notification is sent (when the
|
||||
quality of service flag :data:`cx_Oracle.SUBSCR_QOS_DEREG_NFY` is used).
|
||||
|
||||
.. versionadded:: 6.4
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ registered = True
|
||||
def callback(message):
|
||||
global registered
|
||||
print("Message type:", message.type)
|
||||
if message.type == cx_Oracle.EVENT_DEREG:
|
||||
if not message.registered:
|
||||
print("Deregistration has taken place...")
|
||||
registered = False
|
||||
return
|
||||
|
||||
@ -29,7 +29,7 @@ registered = True
|
||||
def callback(message):
|
||||
global registered
|
||||
print("Message type:", message.type)
|
||||
if message.type == cx_Oracle.EVENT_DEREG:
|
||||
if not message.registered:
|
||||
print("Deregistration has taken place...")
|
||||
registered = False
|
||||
return
|
||||
|
||||
@ -281,6 +281,7 @@ struct cxoMessage {
|
||||
PyObject *queries;
|
||||
PyObject *queueName;
|
||||
PyObject *consumerName;
|
||||
int registered;
|
||||
};
|
||||
|
||||
struct cxoMessageQuery {
|
||||
|
||||
@ -54,6 +54,7 @@ static PyMemberDef cxoMessageTypeMembers[] = {
|
||||
{ "queries", T_OBJECT, offsetof(cxoMessage, queries), READONLY },
|
||||
{ "queueName", T_OBJECT, offsetof(cxoMessage, queueName), READONLY },
|
||||
{ "consumerName", T_OBJECT, offsetof(cxoMessage, consumerName), READONLY },
|
||||
{ "registered", T_BOOL, offsetof(cxoMessage, registered), READONLY },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -406,6 +407,7 @@ static int cxoMessage_initialize(cxoMessage *messageObj,
|
||||
messageObj->subscription = subscription;
|
||||
encoding = subscription->connection->encodingInfo.encoding;
|
||||
messageObj->type = message->eventType;
|
||||
messageObj->registered = message->registered;
|
||||
messageObj->dbname = cxoPyString_fromEncodedString(message->dbName,
|
||||
message->dbNameLength, encoding);
|
||||
if (!messageObj->dbname)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user