Skip to Main Content

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Anastasia.

Asked: March 15, 2017 - 9:58 am UTC

Last updated: March 15, 2017 - 11:12 am UTC

Version: 12c

Viewed 1000+ times

You Asked

Hello, Tom.
I have a pretty long question with, I suppose, pretty short answer required.
I need to develop a solution for asynchronous search in the database.
Being not experienced with Oracle Advanced Queuing, I read something about this mechanism on the Internet, and got the feeling, that it might be the way to go. On the other hand, right now, I cannot afford to spend much time researching about it, just to reveal in the end, that this mechanism is not applicable for my situation. That’s why I am asking you to give a quick overview to the high-level description of the task, and advise me, if it seems like a job to be done by Oracle AQ.
I have database (D) with all customer data, and a partner system (S), that must perform asynchronous searches to reach that data. Interaction must be implemented only by means of Oracle – I mean, the business logic must not be divided, for example, into Oracle layer and layer of some services, implemented in Java.
So, it should be something like that:
S sends a request for the search with an input parameters set in it, and doesn’t wait for a respond from D.
D takes to work this request. It runs a procedure, which performs a search and outputs an XML as a result of it (or an error code).
* And here is my favorite part.
D doesn’t want to store that XML (at least not for the long time), but it needs S to become aware somehow, that its request is done and it can take its XML (and, preferably, clean up the space, taken by that XML).
Such thing about of AQ as dequeuing the message after reading it out, seems very attractive in the context of the task. Same for the opportunity to specify diffetent types of messages, that can be put in a queue and diffetent states for them.
But I don’t clearly understand what can be a producer and a subscriber in D. Can I make a searching procedure the subscriber of the queue (so that it all acts like a trigger on insert into a queue table)? What must be a producer and subscriber on the S side?
Basically, I need a mechanism, which could be implemented via submitting a dbms_job by the call of the request-procedure from S, running a search-procedure and sending a callback from D to S when it’s completed. What prevents me from using dbms_job here is the fact, that all this searching thing must be done in less than 3 seconds, and the minimal interval of launching of jobs committed is, I think, 5 seconds.

So, could you please tell me, if it can be implemented via AQ (without going to deep in details, if it’s very time-consuming)?
Thank you very much in advance.

and Chris said...

Well you can setup callback procedures for your AQ subscribers. These can automatically dequeue the message and run the callback procedure. See examples at:

https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:8760267539329
http://www.oracle-developer.net/display.php?id=411

So I believe what you're asking is possible. I'm not sure precisely how you'll do it given the information you've provided though...

You may also want to read about using the publish-subscribe model in the Oracle Database Development Guide:

http://docs.oracle.com/database/121/ADFNS/adfns_publish.htm#ADFNS014

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library