Further work on adjusting attribute, method and parameter names to be
consistent and to comply with PEP 8 naming guidelines; add a separate section to the documentation to deal with all deprecations so that they are all in one place.
This commit is contained in:
parent
4b72d0de02
commit
c527c06650
@ -25,33 +25,54 @@ used to enqueue and dequeue messages.
|
||||
which the queue was created.
|
||||
|
||||
|
||||
.. method:: Queue.deqMany(maxMessages)
|
||||
.. method:: Queue.deqmany(maxMessages)
|
||||
|
||||
Dequeues up to the specified number of messages from the queue and returns
|
||||
a list of these messages. Each element of the returned list is a
|
||||
:ref:`message property<msgproperties>` object.
|
||||
|
||||
.. versionchanged:: 8.2
|
||||
|
||||
.. method:: Queue.deqOne()
|
||||
For consistency and compliance with the PEP 8 naming style, the name of
|
||||
the method was changed from `deqMany()`. The old name will continue to
|
||||
work for a period of time.
|
||||
|
||||
.. method:: Queue.deqone()
|
||||
|
||||
Dequeues at most one message from the queue. If a message is dequeued, it
|
||||
will be a :ref:`message property<msgproperties>` object; otherwise, it will
|
||||
be the value None.
|
||||
|
||||
.. attribute:: Queue.deqOptions
|
||||
.. versionchanged:: 8.2
|
||||
|
||||
For consistency and compliance with the PEP 8 naming style, the name of
|
||||
the method was changed from `deqOne()`. The old name will continue to
|
||||
work for a period of time.
|
||||
|
||||
.. attribute:: Queue.deqoptions
|
||||
|
||||
This read-only attribute returns a reference to the :ref:`options
|
||||
<deqoptions>` that will be used when dequeuing messages from the queue.
|
||||
|
||||
.. versionchanged:: 8.2
|
||||
|
||||
.. method:: Queue.enqOne(message)
|
||||
For consistency and compliance with the PEP 8 naming style, the name of
|
||||
the attribute was changed from `deqOptions`. The old name will continue
|
||||
to work for a period of time.
|
||||
|
||||
.. method:: Queue.enqone(message)
|
||||
|
||||
Enqueues a single message into the queue. The message must be a
|
||||
:ref:`message property<msgproperties>` object which has had its payload
|
||||
attribute set to a value that the queue supports.
|
||||
|
||||
.. versionchanged:: 8.2
|
||||
|
||||
.. method:: Queue.enqMany(messages)
|
||||
For consistency and compliance with the PEP 8 naming style, the name of
|
||||
the method was changed from `enqone()`. The old name will continue
|
||||
to work for a period of time.
|
||||
|
||||
.. method:: Queue.enqmany(messages)
|
||||
|
||||
Enqueues multiple messages into the queue. The messages parameter must be a
|
||||
sequence containing :ref:`message property <msgproperties>` objects which
|
||||
@ -62,26 +83,38 @@ used to enqueue and dequeue messages.
|
||||
acquired from the same pool may fail due to Oracle bug 29928074. Ensure
|
||||
that this function is not run in parallel, use standalone connections or
|
||||
connections from different pools, or make multiple calls to
|
||||
:meth:`Queue.enqOne()` instead. The function :meth:`Queue.deqMany()`
|
||||
:meth:`Queue.enqone()` instead. The function :meth:`Queue.deqmany()`
|
||||
call is not affected.
|
||||
|
||||
|
||||
.. attribute:: Queue.enqOptions
|
||||
.. attribute:: Queue.enqoptions
|
||||
|
||||
This read-only attribute returns a reference to the :ref:`options
|
||||
<enqoptions>` that will be used when enqueuing messages into the queue.
|
||||
|
||||
.. versionchanged:: 8.2
|
||||
|
||||
For consistency and compliance with the PEP 8 naming style, the name of
|
||||
the attribute was changed from `enqOptions`. The old name will continue
|
||||
to work for a period of time.
|
||||
|
||||
|
||||
.. attribute:: Queue.name
|
||||
|
||||
This read-only attribute returns the name of the queue.
|
||||
|
||||
|
||||
.. attribute:: Queue.payloadType
|
||||
.. attribute:: Queue.payload_type
|
||||
|
||||
This read-only attribute returns the object type for payloads that can be
|
||||
enqueued and dequeued. If using a raw queue, this returns the value None.
|
||||
|
||||
.. versionchanged:: 8.2
|
||||
|
||||
For consistency and compliance with the PEP 8 naming style, the name of
|
||||
the attribute was changed from `payloadType`. The old name will
|
||||
continue to work for a period of time.
|
||||
|
||||
|
||||
.. _deqoptions:
|
||||
|
||||
@ -225,8 +258,8 @@ Message Properties
|
||||
These objects are used to identify the properties of messages that are
|
||||
enqueued and dequeued in queues. They are created by the method
|
||||
:meth:`Connection.msgproperties()`. They are used by the methods
|
||||
:meth:`Queue.enqOne()` and :meth:`Queue.enqMany()` and
|
||||
returned by the methods :meth:`Queue.deqOne()` and :meth:`Queue.deqMany()`.
|
||||
:meth:`Queue.enqone()` and :meth:`Queue.enqmany()` and
|
||||
returned by the methods :meth:`Queue.deqone()` and :meth:`Queue.deqmany()`.
|
||||
|
||||
|
||||
.. attribute:: MessageProperties.attempts
|
||||
|
||||
@ -68,7 +68,7 @@ Connection Object
|
||||
This method is an extension to the DB API definition.
|
||||
|
||||
|
||||
.. attribute:: Connection.callTimeout
|
||||
.. attribute:: Connection.call_timeout
|
||||
|
||||
This read-write attribute specifies the amount of time (in milliseconds)
|
||||
that a single round-trip to the database may take before a timeout will
|
||||
@ -76,6 +76,12 @@ Connection Object
|
||||
|
||||
.. versionadded:: 7.0
|
||||
|
||||
.. versionchanged:: 8.2
|
||||
|
||||
For consistency and compliance with the PEP 8 naming style, the
|
||||
attribute `callTimeout` was renamed to `call_timeout`. The old name
|
||||
will continue to work for a period of time.
|
||||
|
||||
.. note::
|
||||
|
||||
This attribute is an extension to the DB API definition and is only
|
||||
@ -387,6 +393,8 @@ Connection Object
|
||||
This read-only attribute returns the maximum number of bytes each character
|
||||
can use for the client character set.
|
||||
|
||||
.. deprecated:: 8.2
|
||||
|
||||
.. note::
|
||||
|
||||
This attribute is an extension to the DB API definition.
|
||||
@ -469,7 +477,7 @@ Connection Object
|
||||
This method is an extension to the DB API definition.
|
||||
|
||||
|
||||
.. method:: Connection.queue(name, payloadType=None)
|
||||
.. method:: Connection.queue(name, payload_type=None)
|
||||
|
||||
Creates a :ref:`queue <queue>` which is used to enqueue and dequeue
|
||||
messages in Advanced Queueing.
|
||||
@ -477,12 +485,18 @@ Connection Object
|
||||
The name parameter is expected to be a string identifying the queue in
|
||||
which messages are to be enqueued or dequeued.
|
||||
|
||||
The payloadType parameter, if specified, is expected to be an
|
||||
The payload_type parameter, if specified, is expected to be an
|
||||
:ref:`object type <objecttype>` that identifies the type of payload the
|
||||
queue expects. If not specified, RAW data is enqueued and dequeued.
|
||||
|
||||
.. versionadded:: 7.2
|
||||
|
||||
.. versionchanged:: 8.2
|
||||
|
||||
For consistency and compliance with the PEP 8 naming style, the
|
||||
parameter `payloadType` was renamed to `payload_type`. The old name
|
||||
will continue to work as a keyword parameter for a period of time.
|
||||
|
||||
.. note::
|
||||
|
||||
This method is an extension to the DB API definition.
|
||||
|
||||
138
doc/src/api_manual/deprecations.rst
Normal file
138
doc/src/api_manual/deprecations.rst
Normal file
@ -0,0 +1,138 @@
|
||||
.. _deprecations:
|
||||
|
||||
************
|
||||
Deprecations
|
||||
************
|
||||
|
||||
The following tables contains all of the deprecations in the cx_Oracle API,
|
||||
when they were first deprecated and a comment on what should be used instead,
|
||||
if applicable. The most recent deprecations are listed first.
|
||||
|
||||
.. list-table:: Deprecated in 8.2
|
||||
:header-rows: 1
|
||||
:widths: 25 75
|
||||
:width: 100%
|
||||
:name: _deprecations_8_2
|
||||
|
||||
* - Name
|
||||
- Comments
|
||||
* - `encoding` parameter to :meth:`cx_Oracle.connect()`
|
||||
- No longer needed as the use of encodings other than UTF-8 is
|
||||
deprecated.
|
||||
* - `nencoding` parameter to :meth:`cx_Oracle.connect()`
|
||||
- No longer needed as the use of encodings other than UTF-8 is
|
||||
deprecated.
|
||||
* - `encoding` parameter to :meth:`cx_Oracle.SessionPool()`
|
||||
- No longer needed as the use of encodings other than UTF-8 is
|
||||
deprecated.
|
||||
* - `nencoding` parameter to :meth:`cx_Oracle.SessionPool()`
|
||||
- No longer needed as the use of encodings other than UTF-8 is
|
||||
deprecated.
|
||||
* - Connection.maxBytesPerCharacter
|
||||
- No longer needed as the use of encodings other than UTF-8 is
|
||||
deprecated.
|
||||
* - positional parmeters to :meth:`cx_Oracle.connect()`
|
||||
- Replace with keyword parameters in order to comply with the Python
|
||||
database API.
|
||||
* - positional parmeters to :meth:`cx_Oracle.SessionPool()`
|
||||
- Replace with keyword parameters in order to comply with the Python
|
||||
database API.
|
||||
* - `waitTimeout` parameter to :meth:`cx_Oracle.SessionPool()`
|
||||
- Replace with parameter name `wait_timeout`
|
||||
* - `maxLifetimeSession` parameter to :meth:`cx_Oracle.SessionPool()`
|
||||
- Replace with parameter name `max_lifetime_session`
|
||||
* - `sessionCallback` parameter to :meth:`cx_Oracle.SessionPool()`
|
||||
- Replace with parameter name `session_callback`
|
||||
* - `maxSessionsPerShard` parameter to :meth:`cx_Oracle.SessionPool()`
|
||||
- Replace with parameter name `max_sessions_per_shard`
|
||||
* - `payloadType` parameter to :meth:`Connection.queue()`
|
||||
- Replace with parameter name `payload_type` if using keyword parmeters.
|
||||
* - `Connection.callTimeout`
|
||||
- Replace with :data:`Connection.call_timeout`
|
||||
* - `Queue.deqMany`
|
||||
- Replace with :meth:`Queue.deqmany()`
|
||||
* - `Queue.deqOne`
|
||||
- Replace with :meth:`Queue.deqone()`
|
||||
* - `Queue.enqMany`
|
||||
- Replace with :meth:`Queue.enqmany()`
|
||||
* - `Queue.enqOne`
|
||||
- Replace with :meth:`Queue.enqone()`
|
||||
* - `Queue.deqOptions`
|
||||
- Replace with :data:`Queue.deqoptions()`
|
||||
* - `Queue.enqOptions`
|
||||
- Replace with :meth:`Queue.enqoptions()`
|
||||
* - `Queue.payloadType`
|
||||
- Replace with :meth:`Queue.payload_type`
|
||||
|
||||
|
||||
.. list-table:: Deprecated in 8.0
|
||||
:header-rows: 1
|
||||
:widths: 25 75
|
||||
:width: 100%
|
||||
:name: _deprecations_8_0
|
||||
|
||||
* - Name
|
||||
- Comments
|
||||
* - cx_Oracle.BFILE
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_BFILE`
|
||||
* - cx_Oracle.BLOB
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_BLOB`
|
||||
* - cx_Oracle.BOOLEAN
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_BOOLEAN`
|
||||
* - cx_Oracle.CLOB
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_CLOB`
|
||||
* - cx_Oracle.CURSOR
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_CURSOR`
|
||||
* - cx_Oracle.FIXED_CHAR
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_CHAR`
|
||||
* - cx_Oracle.FIXED_NCHAR
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_NCHAR`
|
||||
* - cx_Oracle.INTERVAL
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_INTERVAL_DS`
|
||||
* - cx_Oracle.LONG_BINARY
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_LONG_RAW`
|
||||
* - cx_Oracle.LONG_STRING
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_LONG`
|
||||
* - cx_Oracle.NATIVE_FLOAT
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_BINARY_DOUBLE`
|
||||
* - cx_Oracle.NATIVE_INT
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_BINARY_INTEGER`
|
||||
* - cx_Oracle.NCHAR
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_NVARCHAR`
|
||||
* - cx_Oracle.NCLOB
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_NCLOB`
|
||||
* - cx_Oracle.OBJECT
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_OBJECT`
|
||||
* - cx_Oracle.TIMESTAMP
|
||||
- Replace with :data:`cx_Oracle.DB_TYPE_TIMESTAMP`
|
||||
|
||||
|
||||
.. list-table:: Deprecated in 7.2
|
||||
:header-rows: 1
|
||||
:widths: 25 75
|
||||
:width: 100%
|
||||
:name: _deprecations_7_2
|
||||
|
||||
* - Name
|
||||
- Comments
|
||||
* - Connection.deq()
|
||||
- Replace with :meth:`Queue.deqOne()` or :meth:`Queue.deqMany()`.
|
||||
* - Connection.deqoptions()
|
||||
- Replace with attribute :attr:`Queue.deqOptions`.
|
||||
* - Connection.enq()
|
||||
- Replace with :meth:`Queue.enqOne()` or :meth:`Queue.enqMany()`.
|
||||
* - Connection.enqoptions()
|
||||
- Replace with attribute :attr:`Queue.enqOptions`.
|
||||
|
||||
|
||||
.. list-table:: Deprecated in 6.4
|
||||
:header-rows: 1
|
||||
:widths: 25 75
|
||||
:width: 100%
|
||||
:name: _deprecations_6_4
|
||||
|
||||
* - Name
|
||||
- Comments
|
||||
* - Cursor.executemanyprepared()
|
||||
- Replace with :meth:`~Cursor.executemany()` with None for the statement
|
||||
argument and an integer for the parameters argument.
|
||||
@ -57,6 +57,7 @@ API Manual
|
||||
api_manual/object_type.rst
|
||||
api_manual/aq.rst
|
||||
api_manual/soda.rst
|
||||
api_manual/deprecations.rst
|
||||
|
||||
|
||||
Indices and tables
|
||||
|
||||
@ -24,12 +24,11 @@ Version 8.2 (TBD)
|
||||
<https://github.com/oracle/python-cx_Oracle/issues/530>`__).
|
||||
#) Added check to ensure that when setting variables or object attributes, the
|
||||
type of the temporary LOB must match the expected type.
|
||||
#) All of the parameter names for the :meth:`~cx_Oracle.SessionPool`
|
||||
constructor now follow the PEP 8 naming style. The parameter names
|
||||
`waitTimeout` (use `wait_timeout` instead), `maxLifetimeSession` (use
|
||||
`max_lifetime_session` instead), `sessionCallback` (use `session_callback`
|
||||
instead) and `maxSessionsPerShard` (use `max_sessions_per_shard` instead)
|
||||
are deprecated and will be removed in a subsequent release of cx_Oracle.
|
||||
#) In order to follow the PEP 8 naming style a number of parameter names,
|
||||
method names and attribute names were modified. The old names will be
|
||||
removed in a subsequent release of cx_Oracle. In addition, the use of
|
||||
encodings other than UTF-8 is also deprecated. See
|
||||
:ref:`_deprecations_8_2` for details.
|
||||
#) Improved test suite.
|
||||
|
||||
|
||||
@ -455,7 +454,7 @@ Version 7.0 (September 2018)
|
||||
:ref:`SODA Collection <sodacoll>` and :ref:`SODA Document <sodadoc>` for
|
||||
more information.
|
||||
#) Added support for call timeouts available in Oracle Client 18.1 and
|
||||
higher. See :attr:`Connection.callTimeout`.
|
||||
higher. See :attr:`Connection.call_timeout`.
|
||||
#) Added support for getting the contents of a SQL collection object as a
|
||||
dictionary, where the keys are the indices of the collection and the values
|
||||
are the elements of the collection. See function :meth:`Object.asdict()`.
|
||||
|
||||
@ -17,8 +17,8 @@ import cx_Oracle
|
||||
import sample_env
|
||||
|
||||
connection = cx_Oracle.connect(sample_env.get_main_connect_string())
|
||||
connection.callTimeout = 2000
|
||||
print("Call timeout set at", connection.callTimeout, "milliseconds...")
|
||||
connection.call_timeout = 2000
|
||||
print("Call timeout set at", connection.call_timeout, "milliseconds...")
|
||||
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("select sysdate from dual")
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
# This script demonstrates how to use multi-consumer advanced queuing using
|
||||
# cx_Oracle. It makes use of a RAW queue created in the sample setup.
|
||||
#
|
||||
# This script requires cx_Oracle 7.2 and higher.
|
||||
# This script requires cx_Oracle 8.2 and higher.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
import cx_Oracle
|
||||
@ -32,22 +32,22 @@ cursor = connection.cursor()
|
||||
|
||||
# create queue
|
||||
queue = connection.queue(QUEUE_NAME)
|
||||
queue.deqOptions.wait = cx_Oracle.DEQ_NO_WAIT
|
||||
queue.deqOptions.navigation = cx_Oracle.DEQ_FIRST_MSG
|
||||
queue.deqoptions.wait = cx_Oracle.DEQ_NO_WAIT
|
||||
queue.deqoptions.navigation = cx_Oracle.DEQ_FIRST_MSG
|
||||
|
||||
# enqueue a few messages
|
||||
print("Enqueuing messages...")
|
||||
for data in PAYLOAD_DATA:
|
||||
print(data)
|
||||
queue.enqOne(connection.msgproperties(payload=data))
|
||||
queue.enqone(connection.msgproperties(payload=data))
|
||||
connection.commit()
|
||||
print()
|
||||
|
||||
# dequeue the messages for consumer A
|
||||
print("Dequeuing the messages for consumer A...")
|
||||
queue.deqOptions.consumername = "SUBSCRIBER_A"
|
||||
queue.deqoptions.consumername = "SUBSCRIBER_A"
|
||||
while True:
|
||||
props = queue.deqOne()
|
||||
props = queue.deqone()
|
||||
if not props:
|
||||
break
|
||||
print(props.payload.decode())
|
||||
@ -56,9 +56,9 @@ print()
|
||||
|
||||
# dequeue the message for consumer B
|
||||
print("Dequeuing the messages for consumer B...")
|
||||
queue.deqOptions.consumername = "SUBSCRIBER_B"
|
||||
queue.deqoptions.consumername = "SUBSCRIBER_B"
|
||||
while True:
|
||||
props = queue.deqOne()
|
||||
props = queue.deqone()
|
||||
if not props:
|
||||
break
|
||||
print(props.payload.decode())
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
# cx_Oracle. It makes use of a simple type and queue created in the sample
|
||||
# setup.
|
||||
#
|
||||
# This script requires cx_Oracle 7.2 and higher.
|
||||
# This script requires cx_Oracle 8.2 and higher.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
import cx_Oracle
|
||||
@ -35,13 +35,13 @@ cursor = connection.cursor()
|
||||
|
||||
# create queue
|
||||
books_type = connection.gettype(BOOK_TYPE_NAME)
|
||||
queue = connection.queue(QUEUE_NAME, books_type)
|
||||
queue.deqOptions.wait = cx_Oracle.DEQ_NO_WAIT
|
||||
queue.deqOptions.navigation = cx_Oracle.DEQ_FIRST_MSG
|
||||
queue = connection.queue(QUEUE_NAME, payload_type=books_type)
|
||||
queue.deqoptions.wait = cx_Oracle.DEQ_NO_WAIT
|
||||
queue.deqoptions.navigation = cx_Oracle.DEQ_FIRST_MSG
|
||||
|
||||
# dequeue all existing messages to ensure the queue is empty, just so that
|
||||
# the results are consistent
|
||||
while queue.deqOne():
|
||||
while queue.deqone():
|
||||
pass
|
||||
|
||||
# enqueue a few messages
|
||||
@ -52,13 +52,13 @@ for title, authors, price in BOOK_DATA:
|
||||
book.AUTHORS = authors
|
||||
book.PRICE = price
|
||||
print(title)
|
||||
queue.enqOne(connection.msgproperties(payload=book))
|
||||
queue.enqone(connection.msgproperties(payload=book))
|
||||
connection.commit()
|
||||
|
||||
# dequeue the messages
|
||||
print("\nDequeuing messages...")
|
||||
while True:
|
||||
props = queue.deqOne()
|
||||
props = queue.deqone()
|
||||
if not props:
|
||||
break
|
||||
print(props.payload.TITLE)
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
# This script demonstrates how to use advanced queuing with RAW data using
|
||||
# cx_Oracle. It makes use of a RAW queue created in the sample setup.
|
||||
#
|
||||
# This script requires cx_Oracle 7.2 and higher.
|
||||
# This script requires cx_Oracle 8.2 and higher.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
import cx_Oracle
|
||||
@ -32,25 +32,25 @@ cursor = connection.cursor()
|
||||
|
||||
# create queue
|
||||
queue = connection.queue(QUEUE_NAME)
|
||||
queue.deqOptions.wait = cx_Oracle.DEQ_NO_WAIT
|
||||
queue.deqOptions.navigation = cx_Oracle.DEQ_FIRST_MSG
|
||||
queue.deqoptions.wait = cx_Oracle.DEQ_NO_WAIT
|
||||
queue.deqoptions.navigation = cx_Oracle.DEQ_FIRST_MSG
|
||||
|
||||
# dequeue all existing messages to ensure the queue is empty, just so that
|
||||
# the results are consistent
|
||||
while queue.deqOne():
|
||||
while queue.deqone():
|
||||
pass
|
||||
|
||||
# enqueue a few messages
|
||||
print("Enqueuing messages...")
|
||||
for data in PAYLOAD_DATA:
|
||||
print(data)
|
||||
queue.enqOne(connection.msgproperties(payload=data))
|
||||
queue.enqone(connection.msgproperties(payload=data))
|
||||
connection.commit()
|
||||
|
||||
# dequeue the messages
|
||||
print("\nDequeuing messages...")
|
||||
while True:
|
||||
props = queue.deqOne()
|
||||
props = queue.deqone()
|
||||
if not props:
|
||||
break
|
||||
print(props.payload.decode())
|
||||
|
||||
@ -1348,8 +1348,9 @@ static PyObject *cxoConnection_enqueue(cxoConnection *conn, PyObject* args,
|
||||
static PyObject *cxoConnection_queue(cxoConnection *conn, PyObject* args,
|
||||
PyObject* keywordArgs)
|
||||
{
|
||||
static char *keywordList[] = { "name", "payloadType", NULL };
|
||||
cxoObjectType *typeObj;
|
||||
static char *keywordList[] = { "name", "payload_type", "payloadType",
|
||||
NULL };
|
||||
cxoObjectType *typeObj, *deprecatedTypeObj;
|
||||
cxoBuffer nameBuffer;
|
||||
PyObject *nameObj;
|
||||
dpiQueue *handle;
|
||||
@ -1357,12 +1358,21 @@ static PyObject *cxoConnection_queue(cxoConnection *conn, PyObject* args,
|
||||
int status;
|
||||
|
||||
// parse arguments
|
||||
typeObj = NULL;
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywordArgs, "O|O!", keywordList,
|
||||
&nameObj, &cxoPyTypeObjectType, &typeObj))
|
||||
typeObj = deprecatedTypeObj = NULL;
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywordArgs, "O|O!O!", keywordList,
|
||||
&nameObj, &cxoPyTypeObjectType, &typeObj, &cxoPyTypeObjectType,
|
||||
&deprecatedTypeObj))
|
||||
return NULL;
|
||||
if (cxoConnection_isConnected(conn) < 0)
|
||||
return NULL;
|
||||
if (deprecatedTypeObj) {
|
||||
if (typeObj) {
|
||||
cxoError_raiseFromString(cxoProgrammingErrorException,
|
||||
"payload_type and payloadType cannot both be specified");
|
||||
return NULL;
|
||||
}
|
||||
typeObj = deprecatedTypeObj;
|
||||
}
|
||||
if (cxoBuffer_fromObject(&nameBuffer, nameObj,
|
||||
conn->encodingInfo.encoding) < 0)
|
||||
return NULL;
|
||||
@ -1964,7 +1974,7 @@ static PyGetSetDef cxoCalcMembers[] = {
|
||||
{ "version", (getter) cxoConnection_getVersion, 0, 0, 0 },
|
||||
{ "encoding", (getter) cxoConnection_getEncoding, 0, 0, 0 },
|
||||
{ "nencoding", (getter) cxoConnection_getNationalEncoding, 0, 0, 0 },
|
||||
{ "callTimeout", (getter) cxoConnection_getCallTimeout,
|
||||
{ "call_timeout", (getter) cxoConnection_getCallTimeout,
|
||||
(setter) cxoConnection_setCallTimeout, 0, 0 },
|
||||
{ "maxBytesPerCharacter", (getter) cxoConnection_getMaxBytesPerCharacter,
|
||||
0, 0, 0 },
|
||||
@ -2005,6 +2015,8 @@ static PyGetSetDef cxoCalcMembers[] = {
|
||||
&cxoDataErrorException },
|
||||
{ "NotSupportedError", (getter) cxoConnection_getException, NULL, NULL,
|
||||
&cxoNotSupportedErrorException },
|
||||
{ "callTimeout", (getter) cxoConnection_getCallTimeout,
|
||||
(setter) cxoConnection_setCallTimeout, 0, 0 },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
||||
@ -355,6 +355,10 @@ static PyObject *cxoQueue_enqOne(cxoQueue *queue, PyObject *args)
|
||||
// declaration of methods
|
||||
//-----------------------------------------------------------------------------
|
||||
static PyMethodDef cxoMethods[] = {
|
||||
{ "deqmany", (PyCFunction) cxoQueue_deqMany, METH_VARARGS },
|
||||
{ "deqone", (PyCFunction) cxoQueue_deqOne, METH_NOARGS },
|
||||
{ "enqmany", (PyCFunction) cxoQueue_enqMany, METH_VARARGS },
|
||||
{ "enqone", (PyCFunction) cxoQueue_enqOne, METH_VARARGS },
|
||||
{ "deqMany", (PyCFunction) cxoQueue_deqMany, METH_VARARGS },
|
||||
{ "deqOne", (PyCFunction) cxoQueue_deqOne, METH_NOARGS },
|
||||
{ "enqMany", (PyCFunction) cxoQueue_enqMany, METH_VARARGS },
|
||||
@ -368,9 +372,12 @@ static PyMethodDef cxoMethods[] = {
|
||||
//-----------------------------------------------------------------------------
|
||||
static PyMemberDef cxoMembers[] = {
|
||||
{ "connection", T_OBJECT, offsetof(cxoQueue, conn), READONLY },
|
||||
{ "deqoptions", T_OBJECT, offsetof(cxoQueue, deqOptions), READONLY },
|
||||
{ "enqoptions", T_OBJECT, offsetof(cxoQueue, enqOptions), READONLY },
|
||||
{ "name", T_OBJECT, offsetof(cxoQueue, name), READONLY },
|
||||
{ "payload_type", T_OBJECT, offsetof(cxoQueue, payloadType), READONLY },
|
||||
{ "deqOptions", T_OBJECT, offsetof(cxoQueue, deqOptions), READONLY },
|
||||
{ "enqOptions", T_OBJECT, offsetof(cxoQueue, enqOptions), READONLY },
|
||||
{ "name", T_OBJECT, offsetof(cxoQueue, name), READONLY },
|
||||
{ "payloadType", T_OBJECT, offsetof(cxoQueue, payloadType), READONLY },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -33,10 +33,10 @@ class TestCase(test_env.BaseTestCase):
|
||||
def __deq_in_thread(self, results):
|
||||
connection = test_env.get_connection(threaded=True)
|
||||
queue = connection.queue(RAW_QUEUE_NAME)
|
||||
queue.deqOptions.wait = 10
|
||||
queue.deqOptions.navigation = oracledb.DEQ_FIRST_MSG
|
||||
queue.deqoptions.wait = 10
|
||||
queue.deqoptions.navigation = oracledb.DEQ_FIRST_MSG
|
||||
while len(results) < len(RAW_PAYLOAD_DATA):
|
||||
messages = queue.deqMany(5)
|
||||
messages = queue.deqmany(5)
|
||||
if not messages:
|
||||
break
|
||||
for m in messages:
|
||||
@ -45,9 +45,9 @@ class TestCase(test_env.BaseTestCase):
|
||||
|
||||
def __get_and_clear_raw_queue(self):
|
||||
queue = self.connection.queue(RAW_QUEUE_NAME)
|
||||
queue.deqOptions.wait = oracledb.DEQ_NO_WAIT
|
||||
queue.deqOptions.navigation = oracledb.DEQ_FIRST_MSG
|
||||
while queue.deqOne():
|
||||
queue.deqoptions.wait = oracledb.DEQ_NO_WAIT
|
||||
queue.deqoptions.navigation = oracledb.DEQ_FIRST_MSG
|
||||
while queue.deqone():
|
||||
pass
|
||||
self.connection.commit()
|
||||
return queue
|
||||
@ -57,8 +57,8 @@ class TestCase(test_env.BaseTestCase):
|
||||
queue = self.__get_and_clear_raw_queue()
|
||||
messages = [self.connection.msgproperties(payload=d) \
|
||||
for d in RAW_PAYLOAD_DATA]
|
||||
queue.enqMany(messages)
|
||||
messages = queue.deqMany(len(RAW_PAYLOAD_DATA))
|
||||
queue.enqmany(messages)
|
||||
messages = queue.deqmany(len(RAW_PAYLOAD_DATA))
|
||||
data = [m.payload.decode(self.connection.encoding) for m in messages]
|
||||
self.connection.commit()
|
||||
self.assertEqual(data, RAW_PAYLOAD_DATA)
|
||||
@ -66,7 +66,7 @@ class TestCase(test_env.BaseTestCase):
|
||||
def test_2801_dequeue_empty(self):
|
||||
"2801 - test empty bulk dequeue"
|
||||
queue = self.__get_and_clear_raw_queue()
|
||||
messages = queue.deqMany(5)
|
||||
messages = queue.deqmany(5)
|
||||
self.connection.commit()
|
||||
self.assertEqual(messages, [])
|
||||
|
||||
@ -78,8 +78,8 @@ class TestCase(test_env.BaseTestCase):
|
||||
thread.start()
|
||||
messages = [self.connection.msgproperties(payload=d) \
|
||||
for d in RAW_PAYLOAD_DATA]
|
||||
queue.enqOptions.visibility = oracledb.ENQ_IMMEDIATE
|
||||
queue.enqMany(messages)
|
||||
queue.enqoptions.visibility = oracledb.ENQ_IMMEDIATE
|
||||
queue.enqmany(messages)
|
||||
thread.join()
|
||||
self.assertEqual(results, RAW_PAYLOAD_DATA)
|
||||
|
||||
@ -91,11 +91,11 @@ class TestCase(test_env.BaseTestCase):
|
||||
messages = [self.connection.msgproperties(payload=d) \
|
||||
for d in data_to_enqueue[:num]]
|
||||
data_to_enqueue = data_to_enqueue[num:]
|
||||
queue.enqMany(messages)
|
||||
queue.enqmany(messages)
|
||||
self.connection.commit()
|
||||
all_data = []
|
||||
for num in (3, 5, 10):
|
||||
messages = queue.deqMany(num)
|
||||
messages = queue.deqmany(num)
|
||||
all_data.extend(m.payload.decode(self.connection.encoding) \
|
||||
for m in messages)
|
||||
self.connection.commit()
|
||||
@ -106,29 +106,29 @@ class TestCase(test_env.BaseTestCase):
|
||||
queue = self.__get_and_clear_raw_queue()
|
||||
|
||||
# first test with ENQ_ON_COMMIT (commit required)
|
||||
queue.enqOptions.visibility = oracledb.ENQ_ON_COMMIT
|
||||
queue.enqoptions.visibility = oracledb.ENQ_ON_COMMIT
|
||||
props1 = self.connection.msgproperties(payload="A first message")
|
||||
props2 = self.connection.msgproperties(payload="A second message")
|
||||
queue.enqMany([props1, props2])
|
||||
queue.enqmany([props1, props2])
|
||||
other_connection = test_env.get_connection()
|
||||
other_queue = other_connection.queue(RAW_QUEUE_NAME)
|
||||
other_queue.deqOptions.wait = oracledb.DEQ_NO_WAIT
|
||||
other_queue.deqOptions.visibility = oracledb.DEQ_ON_COMMIT
|
||||
messages = other_queue.deqMany(5)
|
||||
other_queue.deqoptions.wait = oracledb.DEQ_NO_WAIT
|
||||
other_queue.deqoptions.visibility = oracledb.DEQ_ON_COMMIT
|
||||
messages = other_queue.deqmany(5)
|
||||
self.assertEqual(len(messages), 0)
|
||||
self.connection.commit()
|
||||
messages = other_queue.deqMany(5)
|
||||
messages = other_queue.deqmany(5)
|
||||
self.assertEqual(len(messages), 2)
|
||||
other_connection.rollback()
|
||||
|
||||
# second test with ENQ_IMMEDIATE (no commit required)
|
||||
queue.enqOptions.visibility = oracledb.ENQ_IMMEDIATE
|
||||
other_queue.deqOptions.visibility = oracledb.DEQ_IMMEDIATE
|
||||
queue.enqMany([props1, props2])
|
||||
messages = other_queue.deqMany(5)
|
||||
queue.enqoptions.visibility = oracledb.ENQ_IMMEDIATE
|
||||
other_queue.deqoptions.visibility = oracledb.DEQ_IMMEDIATE
|
||||
queue.enqmany([props1, props2])
|
||||
messages = other_queue.deqmany(5)
|
||||
self.assertEqual(len(messages), 4)
|
||||
other_connection.rollback()
|
||||
messages = other_queue.deqMany(5)
|
||||
messages = other_queue.deqmany(5)
|
||||
self.assertEqual(len(messages), 0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user