@@ -19,7 +19,7 @@ class TestAQ(BaseTestCase):
1919 ]
2020
2121 def __deqInThread (self , results ):
22- connection = cx_Oracle . connect ( USERNAME , PASSWORD , TNSENTRY )
22+ connection = self . getConnection ( )
2323 booksType = connection .gettype ("UDT_BOOK" )
2424 book = booksType .newobject ()
2525 options = connection .deqoptions ()
@@ -98,6 +98,7 @@ def testDeqOptions(self):
9898 "TEST_TRANSFORMATION" )
9999 self .__verifyAttribute (options , "visibility" , cx_Oracle .ENQ_IMMEDIATE )
100100 self .__verifyAttribute (options , "wait" , 1287 )
101+ self .__verifyAttribute (options , "msgid" , b'mID' )
101102
102103 def testDeqWithWait (self ):
103104 "test waiting for dequeue"
@@ -146,3 +147,144 @@ def testMsgProps(self):
146147 self .__verifyAttribute (props , "priority" , 1 )
147148 self .assertEqual (props .state , cx_Oracle .MSG_READY )
148149
150+ def testVisibilityModeCommit (self ):
151+ "test enqueue visibility option - ENQ_ON_COMMIT"
152+ booksType = self .connection .gettype ("UDT_BOOK" )
153+ book = booksType .newobject ()
154+ book .TITLE , book .AUTHORS , book .PRICE = self .bookData [0 ]
155+ enqOptions = self .connection .enqoptions ()
156+ enqOptions .visibility = cx_Oracle .ENQ_ON_COMMIT
157+ props = self .connection .msgproperties ()
158+ self .connection .enq ("BOOKS" , enqOptions , props , book )
159+
160+ otherConnection = self .getConnection ()
161+ deqOptions = otherConnection .deqoptions ()
162+ deqOptions .navigation = cx_Oracle .DEQ_FIRST_MSG
163+ deqOptions .wait = cx_Oracle .DEQ_NO_WAIT
164+ booksType = otherConnection .gettype ("UDT_BOOK" )
165+ book = booksType .newobject ()
166+ props = otherConnection .msgproperties ()
167+ messageId = otherConnection .deq ("BOOKS" , deqOptions , props , book )
168+ self .assertTrue (messageId is None )
169+
170+ def testVisibilityModeImmediate (self ):
171+ "test enqueue visibility option - ENQ_IMMEDIATE"
172+ booksType = self .connection .gettype ("UDT_BOOK" )
173+ book = booksType .newobject ()
174+ book .TITLE , book .AUTHORS , book .PRICE = self .bookData [0 ]
175+ enqOptions = self .connection .enqoptions ()
176+ enqOptions .visibility = cx_Oracle .ENQ_IMMEDIATE
177+ props = self .connection .msgproperties ()
178+ self .connection .enq ("BOOKS" , enqOptions , props , book )
179+
180+ otherConnection = self .getConnection ()
181+ deqOptions = otherConnection .deqoptions ()
182+ deqOptions .navigation = cx_Oracle .DEQ_FIRST_MSG
183+ deqOptions .visibility = cx_Oracle .DEQ_ON_COMMIT
184+ deqOptions .wait = cx_Oracle .DEQ_NO_WAIT
185+ booksType = otherConnection .gettype ("UDT_BOOK" )
186+ book = booksType .newobject ()
187+ props = otherConnection .msgproperties ()
188+ otherConnection .deq ("BOOKS" , deqOptions , props , book )
189+ results = (book .TITLE , book .AUTHORS , book .PRICE )
190+ otherConnection .commit ()
191+ self .assertEqual (results , self .bookData [0 ])
192+
193+ def testDeliveryModeSameBuffered (self ):
194+ "test enqueue/dequeue delivery modes identical - buffered"
195+ booksType = self .connection .gettype ("UDT_BOOK" )
196+ book = booksType .newobject ()
197+ book .TITLE , book .AUTHORS , book .PRICE = self .bookData [0 ]
198+ enqOptions = self .connection .enqoptions ()
199+ enqOptions .deliverymode = cx_Oracle .MSG_BUFFERED
200+ enqOptions .visibility = cx_Oracle .ENQ_IMMEDIATE
201+ props = self .connection .msgproperties ()
202+ self .connection .enq ("BOOKS" , enqOptions , props , book )
203+
204+ otherConnection = self .getConnection ()
205+ deqOptions = otherConnection .deqoptions ()
206+ deqOptions .deliverymode = cx_Oracle .MSG_BUFFERED
207+ deqOptions .navigation = cx_Oracle .DEQ_FIRST_MSG
208+ deqOptions .visibility = cx_Oracle .DEQ_IMMEDIATE
209+ deqOptions .wait = cx_Oracle .DEQ_NO_WAIT
210+ booksType = otherConnection .gettype ("UDT_BOOK" )
211+ book = booksType .newobject ()
212+ props = otherConnection .msgproperties ()
213+ otherConnection .deq ("BOOKS" , deqOptions , props , book )
214+ results = (book .TITLE , book .AUTHORS , book .PRICE )
215+ otherConnection .commit ()
216+ self .assertEqual (results , self .bookData [0 ])
217+
218+ def testDeliveryModeSamePersistent (self ):
219+ "test enqueue/dequeue delivery modes identical - persistent"
220+ booksType = self .connection .gettype ("UDT_BOOK" )
221+ book = booksType .newobject ()
222+ book .TITLE , book .AUTHORS , book .PRICE = self .bookData [0 ]
223+ enqOptions = self .connection .enqoptions ()
224+ enqOptions .deliverymode = cx_Oracle .MSG_PERSISTENT
225+ enqOptions .visibility = cx_Oracle .ENQ_IMMEDIATE
226+ props = self .connection .msgproperties ()
227+ self .connection .enq ("BOOKS" , enqOptions , props , book )
228+
229+ otherConnection = self .getConnection ()
230+ deqOptions = otherConnection .deqoptions ()
231+ deqOptions .deliverymode = cx_Oracle .MSG_PERSISTENT
232+ deqOptions .navigation = cx_Oracle .DEQ_FIRST_MSG
233+ deqOptions .visibility = cx_Oracle .DEQ_IMMEDIATE
234+ deqOptions .wait = cx_Oracle .DEQ_NO_WAIT
235+ booksType = otherConnection .gettype ("UDT_BOOK" )
236+ book = booksType .newobject ()
237+ props = otherConnection .msgproperties ()
238+ otherConnection .deq ("BOOKS" , deqOptions , props , book )
239+ results = (book .TITLE , book .AUTHORS , book .PRICE )
240+ otherConnection .commit ()
241+ self .assertEqual (results , self .bookData [0 ])
242+
243+ def testDeliveryModeSamePersistentBuffered (self ):
244+ "test enqueue/dequeue delivery modes identical - persistent/buffered"
245+ booksType = self .connection .gettype ("UDT_BOOK" )
246+ book = booksType .newobject ()
247+ book .TITLE , book .AUTHORS , book .PRICE = self .bookData [0 ]
248+ enqOptions = self .connection .enqoptions ()
249+ enqOptions .deliverymode = cx_Oracle .MSG_PERSISTENT_OR_BUFFERED
250+ enqOptions .visibility = cx_Oracle .ENQ_IMMEDIATE
251+ props = self .connection .msgproperties ()
252+ self .connection .enq ("BOOKS" , enqOptions , props , book )
253+
254+ otherConnection = self .getConnection ()
255+ deqOptions = otherConnection .deqoptions ()
256+ deqOptions .deliverymode = cx_Oracle .MSG_PERSISTENT_OR_BUFFERED
257+ deqOptions .navigation = cx_Oracle .DEQ_FIRST_MSG
258+ deqOptions .visibility = cx_Oracle .DEQ_IMMEDIATE
259+ deqOptions .wait = cx_Oracle .DEQ_NO_WAIT
260+ booksType = otherConnection .gettype ("UDT_BOOK" )
261+ book = booksType .newobject ()
262+ props = otherConnection .msgproperties ()
263+ otherConnection .deq ("BOOKS" , deqOptions , props , book )
264+ results = (book .TITLE , book .AUTHORS , book .PRICE )
265+ otherConnection .commit ()
266+ self .assertEqual (results , self .bookData [0 ])
267+
268+ def testDeliveryModeDifferent (self ):
269+ "test enqueue/dequeue delivery modes different"
270+ booksType = self .connection .gettype ("UDT_BOOK" )
271+ book = booksType .newobject ()
272+ book .TITLE , book .AUTHORS , book .PRICE = self .bookData [0 ]
273+ enqOptions = self .connection .enqoptions ()
274+ enqOptions .deliverymode = cx_Oracle .MSG_BUFFERED
275+ enqOptions .visibility = cx_Oracle .ENQ_IMMEDIATE
276+ props = self .connection .msgproperties ()
277+ self .connection .enq ("BOOKS" , enqOptions , props , book )
278+
279+ otherConnection = self .getConnection ()
280+ deqOptions = otherConnection .deqoptions ()
281+ deqOptions .deliverymode = cx_Oracle .MSG_PERSISTENT
282+ deqOptions .navigation = cx_Oracle .DEQ_FIRST_MSG
283+ deqOptions .visibility = cx_Oracle .DEQ_IMMEDIATE
284+ deqOptions .wait = cx_Oracle .DEQ_NO_WAIT
285+ booksType = otherConnection .gettype ("UDT_BOOK" )
286+ book = booksType .newobject ()
287+ props = otherConnection .msgproperties ()
288+ messageId = otherConnection .deq ("BOOKS" , deqOptions , props , book )
289+ self .assertTrue (messageId is None )
290+
0 commit comments