Rename queues and queue tables to be more clear as to which is which.

This commit is contained in:
Anthony Tuininga 2019-06-11 19:13:21 -06:00
parent c82ae6880d
commit ee5fe39544
6 changed files with 50 additions and 41 deletions

View File

@ -21,7 +21,7 @@ from __future__ import print_function
import cx_Oracle import cx_Oracle
import SampleEnv import SampleEnv
QUEUE_NAME = "DEMORAW" QUEUE_NAME = "DEMO_RAW_QUEUE"
PAYLOAD_DATA = [ PAYLOAD_DATA = [
"The first message", "The first message",
"The second message", "The second message",

View File

@ -23,7 +23,7 @@ import SampleEnv
import decimal import decimal
BOOK_TYPE_NAME = "UDT_BOOK" BOOK_TYPE_NAME = "UDT_BOOK"
QUEUE_NAME = "BOOKS" QUEUE_NAME = "DEMO_BOOK_QUEUE"
BOOK_DATA = [ BOOK_DATA = [
("The Fellowship of the Ring", "Tolkien, J.R.R.", ("The Fellowship of the Ring", "Tolkien, J.R.R.",
decimal.Decimal("10.99")), decimal.Decimal("10.99")),

View File

@ -20,7 +20,7 @@ from __future__ import print_function
import cx_Oracle import cx_Oracle
import SampleEnv import SampleEnv
QUEUE_NAME = "DEMORAW" QUEUE_NAME = "DEMO_RAW_QUEUE"
PAYLOAD_DATA = [ PAYLOAD_DATA = [
"The first message", "The first message",
"The second message", "The second message",

View File

@ -193,14 +193,16 @@ create table &main_user..PlsqlSessionCallbacks (
-- create queue table and queues for demonstrating advanced queuing -- create queue table and queues for demonstrating advanced queuing
begin begin
dbms_aqadm.create_queue_table('&main_user..BOOK_QUEUE', dbms_aqadm.create_queue_table('&main_user..BOOK_QUEUE_TAB',
'&main_user..UDT_BOOK'); '&main_user..UDT_BOOK');
dbms_aqadm.create_queue('&main_user..BOOKS', '&main_user..BOOK_QUEUE'); dbms_aqadm.create_queue('&main_user..DEMO_BOOK_QUEUE',
dbms_aqadm.start_queue('&main_user..BOOKS'); '&main_user..BOOK_QUEUE_TAB');
dbms_aqadm.start_queue('&main_user..DEMO_BOOK_QUEUE');
dbms_aqadm.create_queue_table('&main_user..RAW_QUEUE', 'RAW'); dbms_aqadm.create_queue_table('&main_user..RAW_QUEUE_TAB', 'RAW');
dbms_aqadm.create_queue('&main_user..DEMORAW', '&main_user..RAW_QUEUE'); dbms_aqadm.create_queue('&main_user..DEMO_RAW_QUEUE',
dbms_aqadm.start_queue('&main_user..DEMORAW'); '&main_user..RAW_QUEUE_TAB');
dbms_aqadm.start_queue('&main_user..DEMO_RAW_QUEUE');
end; end;
/ /

View File

@ -11,6 +11,7 @@ import decimal
import threading import threading
class TestCase(TestEnv.BaseTestCase): class TestCase(TestEnv.BaseTestCase):
bookQueueName = "TEST_BOOK_QUEUE"
bookData = [ bookData = [
("Wings of Fire", "A.P.J. Abdul Kalam", ("Wings of Fire", "A.P.J. Abdul Kalam",
decimal.Decimal("15.75")), decimal.Decimal("15.75")),
@ -28,7 +29,7 @@ class TestCase(TestEnv.BaseTestCase):
options.deliverymode = cx_Oracle.MSG_PERSISTENT_OR_BUFFERED options.deliverymode = cx_Oracle.MSG_PERSISTENT_OR_BUFFERED
options.visibility = cx_Oracle.ENQ_IMMEDIATE options.visibility = cx_Oracle.ENQ_IMMEDIATE
props = self.connection.msgproperties() props = self.connection.msgproperties()
while self.connection.deq("BOOKS", options, props, book): while self.connection.deq(self.bookQueueName, options, props, book):
pass pass
def __deqInThread(self, results): def __deqInThread(self, results):
@ -38,7 +39,7 @@ class TestCase(TestEnv.BaseTestCase):
options = connection.deqoptions() options = connection.deqoptions()
options.wait = 10 options.wait = 10
props = connection.msgproperties() props = connection.msgproperties()
if connection.deq("BOOKS", options, props, book): if connection.deq(self.bookQueueName, options, props, book):
results.append((book.TITLE, book.AUTHORS, book.PRICE)) results.append((book.TITLE, book.AUTHORS, book.PRICE))
connection.commit() connection.commit()
@ -54,7 +55,8 @@ class TestCase(TestEnv.BaseTestCase):
options = self.connection.deqoptions() options = self.connection.deqoptions()
options.wait = cx_Oracle.DEQ_NO_WAIT options.wait = cx_Oracle.DEQ_NO_WAIT
props = self.connection.msgproperties() props = self.connection.msgproperties()
messageId = self.connection.deq("BOOKS", options, props, book) messageId = self.connection.deq(self.bookQueueName, options, props,
book)
self.assertTrue(messageId is None) self.assertTrue(messageId is None)
def testDeqEnq(self): def testDeqEnq(self):
@ -68,12 +70,12 @@ class TestCase(TestEnv.BaseTestCase):
book.TITLE = title book.TITLE = title
book.AUTHORS = authors book.AUTHORS = authors
book.PRICE = price book.PRICE = price
self.connection.enq("BOOKS", options, props, book) self.connection.enq(self.bookQueueName, options, props, book)
options = self.connection.deqoptions() options = self.connection.deqoptions()
options.navigation = cx_Oracle.DEQ_FIRST_MSG options.navigation = cx_Oracle.DEQ_FIRST_MSG
options.wait = cx_Oracle.DEQ_NO_WAIT options.wait = cx_Oracle.DEQ_NO_WAIT
results = [] results = []
while self.connection.deq("BOOKS", options, props, book): while self.connection.deq(self.bookQueueName, options, props, book):
row = (book.TITLE, book.AUTHORS, book.PRICE) row = (book.TITLE, book.AUTHORS, book.PRICE)
results.append(row) results.append(row)
self.connection.commit() self.connection.commit()
@ -90,13 +92,14 @@ class TestCase(TestEnv.BaseTestCase):
book.PRICE = price book.PRICE = price
options = self.connection.enqoptions() options = self.connection.enqoptions()
props = self.connection.msgproperties() props = self.connection.msgproperties()
self.connection.enq("BOOKS", options, props, book) self.connection.enq(self.bookQueueName, options, props, book)
options = self.connection.deqoptions() options = self.connection.deqoptions()
options.navigation = cx_Oracle.DEQ_FIRST_MSG options.navigation = cx_Oracle.DEQ_FIRST_MSG
options.wait = cx_Oracle.DEQ_NO_WAIT options.wait = cx_Oracle.DEQ_NO_WAIT
options.mode = cx_Oracle.DEQ_REMOVE_NODATA options.mode = cx_Oracle.DEQ_REMOVE_NODATA
book = booksType.newobject() book = booksType.newobject()
messageId = self.connection.deq("BOOKS", options, props, book) messageId = self.connection.deq(self.bookQueueName, options, props,
book)
self.connection.commit() self.connection.commit()
self.assertTrue(messageId is not None) self.assertTrue(messageId is not None)
self.assertEqual(book.TITLE, "") self.assertEqual(book.TITLE, "")
@ -131,7 +134,7 @@ class TestCase(TestEnv.BaseTestCase):
book.PRICE = price book.PRICE = price
options = self.connection.enqoptions() options = self.connection.enqoptions()
props = self.connection.msgproperties() props = self.connection.msgproperties()
self.connection.enq("BOOKS", options, props, book) self.connection.enq(self.bookQueueName, options, props, book)
self.connection.commit() self.connection.commit()
thread.join() thread.join()
self.assertEqual(results, [(title, authors, price)]) self.assertEqual(results, [(title, authors, price)])
@ -147,11 +150,11 @@ class TestCase(TestEnv.BaseTestCase):
book = booksType.newobject() book = booksType.newobject()
options = self.connection.enqoptions() options = self.connection.enqoptions()
props = self.connection.msgproperties() props = self.connection.msgproperties()
self.assertRaises(TypeError, self.connection.deq, "BOOKS", options, self.assertRaises(TypeError, self.connection.deq, self.bookQueueName,
props, book) options, props, book)
options = self.connection.deqoptions() options = self.connection.deqoptions()
self.assertRaises(TypeError, self.connection.enq, "BOOKS", options, self.assertRaises(TypeError, self.connection.enq, self.bookQueueName,
props, book) options, props, book)
def testMsgProps(self): def testMsgProps(self):
"test getting/setting message properties attributes" "test getting/setting message properties attributes"
@ -175,7 +178,7 @@ class TestCase(TestEnv.BaseTestCase):
enqOptions = self.connection.enqoptions() enqOptions = self.connection.enqoptions()
enqOptions.visibility = cx_Oracle.ENQ_ON_COMMIT enqOptions.visibility = cx_Oracle.ENQ_ON_COMMIT
props = self.connection.msgproperties() props = self.connection.msgproperties()
self.connection.enq("BOOKS", enqOptions, props, book) self.connection.enq(self.bookQueueName, enqOptions, props, book)
otherConnection = TestEnv.GetConnection() otherConnection = TestEnv.GetConnection()
deqOptions = otherConnection.deqoptions() deqOptions = otherConnection.deqoptions()
@ -184,10 +187,12 @@ class TestCase(TestEnv.BaseTestCase):
booksType = otherConnection.gettype("UDT_BOOK") booksType = otherConnection.gettype("UDT_BOOK")
book = booksType.newobject() book = booksType.newobject()
props = otherConnection.msgproperties() props = otherConnection.msgproperties()
messageId = otherConnection.deq("BOOKS", deqOptions, props, book) messageId = otherConnection.deq(self.bookQueueName, deqOptions, props,
book)
self.assertTrue(messageId is None) self.assertTrue(messageId is None)
self.connection.commit() self.connection.commit()
messageId = otherConnection.deq("BOOKS", deqOptions, props, book) messageId = otherConnection.deq(self.bookQueueName, deqOptions, props,
book)
self.assertTrue(messageId is not None) self.assertTrue(messageId is not None)
def testVisibilityModeImmediate(self): def testVisibilityModeImmediate(self):
@ -199,7 +204,7 @@ class TestCase(TestEnv.BaseTestCase):
enqOptions = self.connection.enqoptions() enqOptions = self.connection.enqoptions()
enqOptions.visibility = cx_Oracle.ENQ_IMMEDIATE enqOptions.visibility = cx_Oracle.ENQ_IMMEDIATE
props = self.connection.msgproperties() props = self.connection.msgproperties()
self.connection.enq("BOOKS", enqOptions, props, book) self.connection.enq(self.bookQueueName, enqOptions, props, book)
otherConnection = TestEnv.GetConnection() otherConnection = TestEnv.GetConnection()
deqOptions = otherConnection.deqoptions() deqOptions = otherConnection.deqoptions()
@ -209,7 +214,7 @@ class TestCase(TestEnv.BaseTestCase):
booksType = otherConnection.gettype("UDT_BOOK") booksType = otherConnection.gettype("UDT_BOOK")
book = booksType.newobject() book = booksType.newobject()
props = otherConnection.msgproperties() props = otherConnection.msgproperties()
otherConnection.deq("BOOKS", deqOptions, props, book) otherConnection.deq(self.bookQueueName, deqOptions, props, book)
results = (book.TITLE, book.AUTHORS, book.PRICE) results = (book.TITLE, book.AUTHORS, book.PRICE)
otherConnection.commit() otherConnection.commit()
self.assertEqual(results, self.bookData[0]) self.assertEqual(results, self.bookData[0])
@ -224,7 +229,7 @@ class TestCase(TestEnv.BaseTestCase):
enqOptions.deliverymode = cx_Oracle.MSG_BUFFERED enqOptions.deliverymode = cx_Oracle.MSG_BUFFERED
enqOptions.visibility = cx_Oracle.ENQ_IMMEDIATE enqOptions.visibility = cx_Oracle.ENQ_IMMEDIATE
props = self.connection.msgproperties() props = self.connection.msgproperties()
self.connection.enq("BOOKS", enqOptions, props, book) self.connection.enq(self.bookQueueName, enqOptions, props, book)
otherConnection = TestEnv.GetConnection() otherConnection = TestEnv.GetConnection()
deqOptions = otherConnection.deqoptions() deqOptions = otherConnection.deqoptions()
@ -235,7 +240,7 @@ class TestCase(TestEnv.BaseTestCase):
booksType = otherConnection.gettype("UDT_BOOK") booksType = otherConnection.gettype("UDT_BOOK")
book = booksType.newobject() book = booksType.newobject()
props = otherConnection.msgproperties() props = otherConnection.msgproperties()
otherConnection.deq("BOOKS", deqOptions, props, book) otherConnection.deq(self.bookQueueName, deqOptions, props, book)
results = (book.TITLE, book.AUTHORS, book.PRICE) results = (book.TITLE, book.AUTHORS, book.PRICE)
otherConnection.commit() otherConnection.commit()
self.assertEqual(results, self.bookData[0]) self.assertEqual(results, self.bookData[0])
@ -250,7 +255,7 @@ class TestCase(TestEnv.BaseTestCase):
enqOptions.deliverymode = cx_Oracle.MSG_PERSISTENT enqOptions.deliverymode = cx_Oracle.MSG_PERSISTENT
enqOptions.visibility = cx_Oracle.ENQ_IMMEDIATE enqOptions.visibility = cx_Oracle.ENQ_IMMEDIATE
props = self.connection.msgproperties() props = self.connection.msgproperties()
self.connection.enq("BOOKS", enqOptions, props, book) self.connection.enq(self.bookQueueName, enqOptions, props, book)
otherConnection = TestEnv.GetConnection() otherConnection = TestEnv.GetConnection()
deqOptions = otherConnection.deqoptions() deqOptions = otherConnection.deqoptions()
@ -261,7 +266,7 @@ class TestCase(TestEnv.BaseTestCase):
booksType = otherConnection.gettype("UDT_BOOK") booksType = otherConnection.gettype("UDT_BOOK")
book = booksType.newobject() book = booksType.newobject()
props = otherConnection.msgproperties() props = otherConnection.msgproperties()
otherConnection.deq("BOOKS", deqOptions, props, book) otherConnection.deq(self.bookQueueName, deqOptions, props, book)
results = (book.TITLE, book.AUTHORS, book.PRICE) results = (book.TITLE, book.AUTHORS, book.PRICE)
otherConnection.commit() otherConnection.commit()
self.assertEqual(results, self.bookData[0]) self.assertEqual(results, self.bookData[0])
@ -276,7 +281,7 @@ class TestCase(TestEnv.BaseTestCase):
enqOptions.deliverymode = cx_Oracle.MSG_PERSISTENT_OR_BUFFERED enqOptions.deliverymode = cx_Oracle.MSG_PERSISTENT_OR_BUFFERED
enqOptions.visibility = cx_Oracle.ENQ_IMMEDIATE enqOptions.visibility = cx_Oracle.ENQ_IMMEDIATE
props = self.connection.msgproperties() props = self.connection.msgproperties()
self.connection.enq("BOOKS", enqOptions, props, book) self.connection.enq(self.bookQueueName, enqOptions, props, book)
otherConnection = TestEnv.GetConnection() otherConnection = TestEnv.GetConnection()
deqOptions = otherConnection.deqoptions() deqOptions = otherConnection.deqoptions()
@ -287,7 +292,7 @@ class TestCase(TestEnv.BaseTestCase):
booksType = otherConnection.gettype("UDT_BOOK") booksType = otherConnection.gettype("UDT_BOOK")
book = booksType.newobject() book = booksType.newobject()
props = otherConnection.msgproperties() props = otherConnection.msgproperties()
otherConnection.deq("BOOKS", deqOptions, props, book) otherConnection.deq(self.bookQueueName, deqOptions, props, book)
results = (book.TITLE, book.AUTHORS, book.PRICE) results = (book.TITLE, book.AUTHORS, book.PRICE)
otherConnection.commit() otherConnection.commit()
self.assertEqual(results, self.bookData[0]) self.assertEqual(results, self.bookData[0])
@ -302,7 +307,7 @@ class TestCase(TestEnv.BaseTestCase):
enqOptions.deliverymode = cx_Oracle.MSG_BUFFERED enqOptions.deliverymode = cx_Oracle.MSG_BUFFERED
enqOptions.visibility = cx_Oracle.ENQ_IMMEDIATE enqOptions.visibility = cx_Oracle.ENQ_IMMEDIATE
props = self.connection.msgproperties() props = self.connection.msgproperties()
self.connection.enq("BOOKS", enqOptions, props, book) self.connection.enq(self.bookQueueName, enqOptions, props, book)
otherConnection = TestEnv.GetConnection() otherConnection = TestEnv.GetConnection()
deqOptions = otherConnection.deqoptions() deqOptions = otherConnection.deqoptions()
@ -313,7 +318,8 @@ class TestCase(TestEnv.BaseTestCase):
booksType = otherConnection.gettype("UDT_BOOK") booksType = otherConnection.gettype("UDT_BOOK")
book = booksType.newobject() book = booksType.newobject()
props = otherConnection.msgproperties() props = otherConnection.msgproperties()
messageId = otherConnection.deq("BOOKS", deqOptions, props, book) messageId = otherConnection.deq(self.bookQueueName, deqOptions, props,
book)
self.assertTrue(messageId is None) self.assertTrue(messageId is None)
def testDequeueTransformation(self): def testDequeueTransformation(self):
@ -325,7 +331,7 @@ class TestCase(TestEnv.BaseTestCase):
expectedPrice = book.PRICE + 10 expectedPrice = book.PRICE + 10
enqOptions = self.connection.enqoptions() enqOptions = self.connection.enqoptions()
props = self.connection.msgproperties() props = self.connection.msgproperties()
self.connection.enq("BOOKS", enqOptions, props, book) self.connection.enq(self.bookQueueName, enqOptions, props, book)
self.connection.commit() self.connection.commit()
otherConnection = TestEnv.GetConnection() otherConnection = TestEnv.GetConnection()
@ -337,7 +343,7 @@ class TestCase(TestEnv.BaseTestCase):
booksType = otherConnection.gettype("UDT_BOOK") booksType = otherConnection.gettype("UDT_BOOK")
book = booksType.newobject() book = booksType.newobject()
props = otherConnection.msgproperties() props = otherConnection.msgproperties()
otherConnection.deq("BOOKS", deqOptions, props, book) otherConnection.deq(self.bookQueueName, deqOptions, props, book)
otherPrice = book.PRICE otherPrice = book.PRICE
self.assertEqual(otherPrice, expectedPrice) self.assertEqual(otherPrice, expectedPrice)
@ -351,7 +357,7 @@ class TestCase(TestEnv.BaseTestCase):
enqOptions = self.connection.enqoptions() enqOptions = self.connection.enqoptions()
enqOptions.transformation = "%s.transform1" % self.connection.username enqOptions.transformation = "%s.transform1" % self.connection.username
props = self.connection.msgproperties() props = self.connection.msgproperties()
self.connection.enq("BOOKS", enqOptions, props, book) self.connection.enq(self.bookQueueName, enqOptions, props, book)
self.connection.commit() self.connection.commit()
otherConnection = TestEnv.GetConnection() otherConnection = TestEnv.GetConnection()
@ -362,7 +368,7 @@ class TestCase(TestEnv.BaseTestCase):
booksType = otherConnection.gettype("UDT_BOOK") booksType = otherConnection.gettype("UDT_BOOK")
book = booksType.newobject() book = booksType.newobject()
props = otherConnection.msgproperties() props = otherConnection.msgproperties()
otherConnection.deq("BOOKS", deqOptions, props, book) otherConnection.deq(self.bookQueueName, deqOptions, props, book)
otherPrice = book.PRICE otherPrice = book.PRICE
self.assertEqual(otherPrice, expectedPrice) self.assertEqual(otherPrice, expectedPrice)

View File

@ -255,10 +255,11 @@ create table &main_user..PlsqlSessionCallbacks (
-- create queue table and queues for testing advanced queuing -- create queue table and queues for testing advanced queuing
begin begin
dbms_aqadm.create_queue_table('&main_user..BOOK_QUEUE', dbms_aqadm.create_queue_table('&main_user..BOOK_QUEUE_TAB',
'&main_user..UDT_BOOK'); '&main_user..UDT_BOOK');
dbms_aqadm.create_queue('&main_user..BOOKS', '&main_user..BOOK_QUEUE'); dbms_aqadm.create_queue('&main_user..TEST_BOOK_QUEUE',
dbms_aqadm.start_queue('&main_user..BOOKS'); '&main_user..BOOK_QUEUE_TAB');
dbms_aqadm.start_queue('&main_user..TEST_BOOK_QUEUE');
end; end;
/ /