Reputation: 13
I am trying to connect to an Oracle advanced queue using Python.
The basic principle of what I am trying to do is this: A queue has been set up that will send a message once every hour, I want to deque this message and analyze it with some code I've written.
I have credentials (host, port, sid, user & passwn) but I am not sure how to set up the connection and start consuming.
From what I can understand from previous questions on the web the cx_oracle module should have capabilities to do this, but I cannot figure out how to do this in practice.
If you have any links to tutorials that shows how this is done, or if you have some sample code yourself It would be highly appreciated. I have some experiece with RabbitMQ queues but it seems that there is alot less examples and tutorials for Oracle AQ, hence my question here.
Upvotes: 1
Views: 1740
Reputation: 29680
The cx_Oracle Advanced Queuing docs are here.
An example would be something like:
# setup connection
connection = cx_Oracle.Connection('connection string')
# get the options
options = connection.deqoptions()
# set relevant options:
options.navigation = cx_Oracle.DEQ_FIRST_MSG
options.wait = cx_Oracle.DEQ_WAIT_FOREVER
# continuously deque
while connection.deq(NAME_OF_QUEUE, options, messageProperties, payload):
print(payload)
Anthony Tuininga (cx_Oracle author) has a much more complete example on Github.
Upvotes: 1