Queue Concurrent Processing using PL/SQL notification
I have a queue that I need to have the processing done concurrently no matter how many messages are in the queue. Currently one 1 message is processed at a time, but I need at least 10 processed at once. Each message could take up to 3 minutes to process so doing one at a time is taking too long when the number of messages grows to more than 5 or 10. How can this be done?
begin
DBMS_AQADM.CREATE_QUEUE_TABLE
( queue_table => 'z3.health_check_qtab',
queue_payload_type => 'z3.sil_queue_msg_typ',
multiple_consumers => TRUE );
DBMS_AQADM.CREATE_QUEUE
( queue_name => 'HEALTH_CHECK_Q',
queue_table => 'z3.health_check_qtab');
DBMS_AQADM.START_QUEUE
( queue_name => 'HEALTH_CHECK_Q');
end;
begin
dbms_aqadm.add_subscriber
( queue_name => 'Z3.HEALTH_CHECK_Q',
subscriber => sys.aq$_agent( 'HC_recipient1', null, null ) );
end;
BEGIN
dbms_aq.register
( sys.aq$_reg_info_list(
sys.aq$_reg_info('Z3.HEALTH_CHECK_Q:HC_RECIPIENT1',
DBMS_AQ.NAMESPACE_AQ,
'plsql://Z3.Z_IMPACT_LIST_PKG.DEQUEUE_HEALTH_CHECK',
HEXTORAW('FF')) ) ,
1 );
end;
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
I'm also looking into how to do this (on 10gR2 RAC). I would like to enqueue say 1,000,000 requests and have 10-30 (configurable) worker 'threads' dequeueing and executing a PL/SQL procedure during certain parts of the day.
Similar Messages
-
Performance of AQ when using callback procedure (using PL/SQL notification)
I am enqueueing XMLType in AQ.XML file is large in size.NOw I want to dequeue the AQ using PL/SQL notification(using callback procedure which will call DBMS_AQ.DEQUEUE to dequeue the AQ and process the XML.After fetching the data from XML ,I want to store these data in another table columns).
Please suggest,In this case which approach would be better to dequeue the AQ table :
1.PL/SQL notification(using callback procedure)
OR
2.Scheduling the call to DBMS_AQ.DEQUEUE to dequeue the AQ table
What would be the impact on performance of above two approaches?Hi,
The question of performance is not down to the technique one employes to enqueue/dequeue, but at a basic level, is relative to the number of messages!
The is what the Oracle documentation states:
>
When persistent messages are enqueued, they are stored in database tables. The performance characteristics of queue operations on persistent messages are similar to underlying database operations. The code path of an enqueue operation is comparable to SELECT and INSERT into a multicolumn queue table with three index-organized tables. The code path of a dequeue operation is comparable to SELECT, DELETE, and UPDATE operations on similar tables.
>
So, if anything, the dequeue is a fraction more time & resource consuming. However, it is only a "fraction". You could always add multiple subscribers to dequeue if you want!
You could ofcourse choose to have non-persistent messages if your application does not need the kind of fault-tolerance that persistent messaging offers, which speed things up, but only a bit, so don't get too excited about it!
There are other things to consider however, which you may wish to read up on before getting bogged down on whether you should use notification or the scheduler:
- Is your system clustered?
- Concurrency on a single queue (i.e. multiple enqueues/dequeues, but single queue)
- Propogation latency issues
Read about these and much more at:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14257/perform.htm
Finally, whether you pl/sql notification or not and whether you use dbms_scheduler is down to your application requirements!
P; -
Disable Html button in validation process using pl/sql
Hi,
I need to disable a html page button. It gets re-enabled afer a validation process is run on the page and errors for the form are returned. I need a way of writing a validation process using pl/sql returning boolean, that can disable the button again.
I've tried:
IF lname > 0 THEN
Return TRUE;
Else
htp.p('<script type="text/javascript">');
htp.p('document.getElementById("NEW_ENTRY").disabled=true');
htp.p('</script>');
Return FALSE;
End If;
The button id is NEW_ENTRY, but this is ignored and the buttons remains enabled.
Any ideas on how to change the code to work?You have to create after region process that will be triggered on some condition.
htp.p('
<script type="text/javascript">
document.getElementById("NEW_ENTRY").disabled="true";
</script>
'); -
Single queue: concurrent processing of messages in multiple consumers
Hi,
I am new to jms . The goal is to process messages concurrently from a queue in an asynchronous listener's onMessage method by attaching a listener instance to multiple consumer's with each consumer using its own session and running in a separate thread, that way the messages are passed on to the different consumers for concurrent processing.
1) Is it ossible to process messsages concurrently from a single queue by creating multiple consumers ?
2) I came up with the below code, but would like to get your thoughts on whether the below code looks correct for what I want to accomplish.
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.walmart.platform.jms.client.JMSConnectionFactory;
public class QueueConsumer implements Runnable, MessageListener {
public static void main(String[] args) {
// Create an instance of the client
QueueConsumer consumer1 = new QueueConsumer();
QueueConsumer consumer2 = new QueueConsumer();
try {
consumer1.init("oms","US.Q.CHECKOUT-ORDER.1.0.JSON"); //US.Q.CHECKOUT-ORDER.1.0.JSON is the queue name
consumer2.init("oms","US.Q.CHECKOUT-ORDER.1.0.JSON");
}catch( JMSException ex ){
ex.printStackTrace();
System.exit(-1);
// Start the client running
Thread newThread1 = new Thread(consumer1);
Thread newThread2 = new Thread(consumer1);
newThread1.start();newThread2.start();
InputStreamReader aISR = new InputStreamReader(System.in);
char aAnswer = ' ';
do {
try {
aAnswer = (char) aISR.read();
catch (IOException e)
// TODO Auto-generated catch block
e.printStackTrace();
} while ((aAnswer != 'q') && (aAnswer != 'Q'));
newThread1.interrupt();
newThread2.interrupt();
try {
newThread1.join();newThread2.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out
.println("--------------------exiting main thread------------------------"+Thread.currentThread().getId());
System.exit(0);
// values will be read from a resource properties file
private static String connectionFactoryName = null;
private static String queueName = null;
// thread safe object ref
private static ConnectionFactory qcf = null;
private static Connection queueConnection = null;
// not thread safe
private Session ses = null;
private Destination queue = null;
private MessageConsumer msgConsumer = null;
public static final Logger logger = LoggerFactory
.getLogger(QueueConsumer.class);
public QueueConsumer() {
super();
public void onMessage(Message msg) {
if (msg instanceof TextMessage) {
try {
System.out
.println("listener is "+Thread.currentThread().getId()+"--------------------Message recieved from queue is ------------------------"
+ ((TextMessage) msg).getJMSMessageID());
} catch (JMSException ex) {
ex.printStackTrace();
public void run() {
// Start listening
try {
queueConnection.start();
} catch (JMSException e) {
e.printStackTrace();
System.exit(-1);
while (!Thread.currentThread().isInterrupted()) {
synchronized (this) {
try {
wait();
} catch (InterruptedException ex) {
break;
* This method is called to set up and initialize the necessary Session,
* destination and message listener
* @param queue2
* @param factoryName
public void init(String factoryName, String queue2) throws JMSException {
try {
qcf = new JMSConnectionFactory(factoryName);
/* create the connection */
queueConnection = qcf.createConnection();
* Create a session that is non-transacted and is client
* acknowledged
ses = queueConnection.createSession(false,
Session.CLIENT_ACKNOWLEDGE);
queue = ses.createQueue(queue2);
logger.info("Subscribing to destination: " + queue2);
msgConsumer = ses.createConsumer(queue);
/* set the listener */
msgConsumer.setMessageListener(this);
System.out.println("Listening on queue " +queue2);
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
private static void setConnectionFactoryName(String name) {
connectionFactoryName = name;
private static String getQueueName() {
return queueName;
private static void setQueueName(String name) {
queueName = name;Hi Mark,
if the messages are sent with quality of service EO (=exactly once) you can add queues.
From documentation:
Netweaver XI -> Runtime -> Processing xml messages -> Queues for asynchronous message processing
...For incoming messages you set the parameter EO_INBOUND_PARALLEL from the Tuning category.
If more than one message is sent to the same receiver, use the configuration parameter EO_OUTBOUND_PARALLEL of the Tuning category to process messages simultaneously in different queues.
Transaction: SXMB_ADM
Regards
Holger -
READ CONCURRENT OUTPUT USING PL/SQL
Hi,
Environment - multi node.
Is there any possibility for reading concurrent request output from db node using pl/sql coding.
Rgds,
SathyaSTEP - 2
SQL>
SQL> DECLARE
2 l_ctx dbms_xmlsave.ctxType ;
3 l_xml CLOB :=
4 '<?xml version="1.0" encoding="UTF-8" ?>
5 <NewDataSet>
6 <ROW>
7 <DEPARTMENT>BA52</DEPARTMENT>
8 <PCS_CONTRACT_TAG>MD-3GSM</PCS_CONTRACT_TAG>
9 <LOCATION>Australia</LOCATION>
10 <MAY_2006>21668</MAY_2006>
11 </ROW>
12 <ROW>
13 <DEPARTMENT>BA501</DEPARTMENT>
14 <PCS_CONTRACT_TAG>MD-3GSM</PCS_CONTRACT_TAG>
15 <LOCATION>China</LOCATION>
16 <MAY_2006>8166</MAY_2006>
17 </ROW>
18 <ROW>
19 <DEPARTMENT>BA522</DEPARTMENT>
20 <PCS_CONTRACT_TAG>MD-3GSM</PCS_CONTRACT_TAG>
21 <LOCATION>Australia</LOCATION>
22 <MAY_2006>21668</MAY_2006>
23 </ROW>
24 </NewDataSet>' ;
25 BEGIN
26 l_ctx := dbms_xmlsave.newContext(targetTable => 'XML_INSERT');
27 dbms_output.put_line(dbms_xmlsave.insertXML(ctxHdl => l_ctx,
28 xDoc => l_xml) ||
29 ' rows inserted.');
30 dbms_xmlsave.closeContext(l_ctx);
31 END;
32 /
3 rows inserted.
PL/SQL procedure successfully completed.Regards.
Satyaki De. -
Possible to run several concurrent processes form pl/sql in background
Hi,
We have a procedure in package in pl/sql which we pass in year and month to.
Rather than run these processese serially
package.procedure(201301);
package.procedure (201302); etc
would like to have these run concurrently in paralllel.
What is best way to do this.
Only way I can think of is dbms_scheduler to do run once only for each of the jobs
Using oracle 11.2.0.3
ThanksYou have already posted the solution so mark your thread ANSWERED and give yourself 10 points!
-
PL/SQL notification is not working
Hi,
We are using PL/SQL notification procedure to de-queue AQ in our application. Now the notification is not working in development instance whereas it is working in Live. The database parameter job_queue_processes was having value 0 in development database and it is now reset to 10. Still the problem exists. Please let us know what could be other reasons for failure of PL/SQL notification in AQ.
Thanks
SreeshaNo version number.
No DDL.
No DML.
No error messages.
As already stated no clear understanding of what isn't working
But equally important no clear understanding of what you implemented and how.
If you want help you must be specific. -
BI publisher concurrent comes back with warning trying to use PL/SQL
Hello,
I am new to BI publisher and I am trying to use PL/SQL to generate XML and have the Publisher display the report with a template I have created. The concurrent is completing with a warning and from looking at the other forum posts I found the following in the OPP error logs...
Template code:XML_TEST
Template app: XML
Language: en
Territory: 00
Output type: RTF
[3/2/11 2:27:37 PM] [393078:RT2163613] Output file was found but is zero sized - Deleted
[3/2/11 2:27:37 PM] [UNEXPECTED] [393078:RT2163613] java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at oracle.apps.xdo.common.xml.XSLT10gR1.invokeNewXSLStylesheet(XSLT10gR1.java:611)
at oracle.apps.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:239)
at oracle.apps.xdo.common.xml.XSLTWrapper.transform(XSLTWrapper.java:182)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:1044)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:997)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:212)
at oracle.apps.xdo.template.FOProcessor.createFO(FOProcessor.java:1665)
at oracle.apps.xdo.template.FOProcessor.generate(FOProcessor.java:975)
at oracle.apps.xdo.oa.schema.server.TemplateHelper.runProcessTemplate(TemplateHelper.java:5936)
at oracle.apps.xdo.oa.schema.server.TemplateHelper.processTemplate(TemplateHelper.java:3459)
at oracle.apps.xdo.oa.schema.server.TemplateHelper.processTemplate(TemplateHelper.java:3548)
at oracle.apps.fnd.cp.opp.XMLPublisherProcessor.process(XMLPublisherProcessor.java:302)
at oracle.apps.fnd.cp.opp.OPPRequestThread.run(OPPRequestThread.java:176)
Caused by: oracle.xdo.parser.v2.XPathException: Namespace prefix 'ref' used but not declared.
at oracle.xdo.parser.v2.XSLProcessor.reportException(XSLProcessor.java:806)
at oracle.xdo.parser.v2.XSLProcessor.newXSLStylesheet(XSLProcessor.java:571)
... 17 more
I am pretty sire the PL/SQL is OK beacuse if I run without a template the XML output is displayed as expected.
Would anyone have any ideas on this?Here's your problem:
"Caused by: oracle.xdo.parser.v2.XPathException: Namespace prefix 'ref' used but not declared.
at oracle.xdo.parser.v2.XSLProcessor.reportException(XSLProcessor.java:806)
at oracle.xdo.parser.v2.XSLProcessor.newXSLStylesheet(XSLProcessor.java:571)
What version of BIP Desktop are you using? From the error message it appears to be Template builder for Word 11.1.1.3. eBS is probably using 5.6.3 .
Try this - edit the fields in the template using MS Word. Under Help or Status, remove tags that contain <?ref.....?>. Save and upload the template.
Hope this helps. If this works, please don't forget to give me points for the right answer. -
Linking PL\SQL procedure as Concurrent Process
Hi.
I'm link PL-proc as concurrent process, and it runs without any
errors.
Now I need also run it as standart report, but can't generate
output file to store any words to.
help.
mailto: [email protected]Thanks for your response.
I am writing a BPEL PM process for inserting AP Invoices by inserting data into the interface tables, and then executing the corresponding concurrent program (APXIIMPT). I would like to trap any errors and send them back to the BPEL process.
One suggestion on how to do this is to write a pl/sql procedure which inserts the data, executes the concurrent program, collects any error messages, and passes them back via OUT parameters. Such a procedure could be called using an adapter from BPEL PM.
So the issue for this forum is how to make the single pl/sql procedure wait for completion of the concurrent process.
Alternatively, is there a business event raised when the concurrent process completes? -
How to send message to a multi-consumer queue using pl/sql
How to send message to a multi-consumer queue using pl/sql ? Thanks.
I tried following, but got an message: no receipient specified.
DBMS_AQ.ENQUEUE(
queue_name => 'aqadm.multi_queue',
enqueue_options => queue_options,
message_properties => message_properties,
payload => my_message,
msgid => message_id);
COMMIT;
END;
/Here's two way to enqueue/publish new message into multi-consumer queue.
(1) Use explicitly declared recipient list
- Specify "Recipients" by setting recipient_list to messge_properties, before ENQUEUE().
DECLARE
recipients DBMS_AQ.aq$_recipient_list_t;
BEGIN
recipients(1) := sys.aq$_agent('RECIPIENTNAME',NULL,NULL);
message_properties.recipient_list := recipients ;
(2)Or, declare subscriber list permanently. Then you need not to specify recipient list each time you call ENQUEUE().
begin
dbms_aqadm.add_subscriber(
queue_name=>'YOURQUEUE',
subscriber=> sys.aq$_agent('RECIPIENTNAME', null, null)
end;
You can add 1024 local subscriber include maximum 32 remote-queue-consumer to one queue. -
How to set the value of application item using pl/sql in application process
Hi guys,
I want a global variable (application item) whose value will be set at the start when a user logs in to the application. The value will be retrieved from database using a sql query. I do not know the exact syntax to set the value of application item in application process. Also i want to know in which type of application process should i use to set the value of application item when a user starts a session. The value of application item varies from user to user.
Please help.
I am using apex 4.2
Regards,
WaqasYou can use the application item as bind-variable with its name. ie. your application item is named G_MY_APPLICATION_ITEM, then you can access/set it using :G_MY_APPLICATION_ITEM.
For example
BEGIN
-- assign like a variable
:G_MY_APPLICATION_ITEM := 'LARRY';
-- use in a SQL statement
SELECT WHATEVER_COLUMN
INTO :G_MY_APPLICATION_ITEM
FROM MY_TABLE
WHERE USERNAME = :APP_USER
END;
Peter -
Calling an On Demand Process in PL/SQL Region without using AJAX
Hi!
I am trying to find a way to call an On demand Process in a PL/SQL Reports Region. The reason is that i need Reportings for about 20 Pages that look like the same but have different parameters. I already have some Processes that return SQL Statements and it works fine. But these Reportings are more complex and it's not possible to return it wirh a SQL Statement.
I have seen some solutions in this forum that used AJAX to call such a process. The problem is, that I'm not allowed to use AJAX because activeX is diabled. I tried it and it works but i need another way to solve this process call.
Thanks in advance
PhilippAt the moment I cannot say if your link can help. Right now the call of the On demand Process looks like this:
Inside annonymous PL/SQL Region:
<script type="text/javascript">
get = new htmldb_Get(null,'||:APP_ID||'.,'APPLICATION_PROCESS=F_REPORT_NAME',0);
gReturn = get.get();
document.write(gReturn);
</script> -
BPEL process to Insert XML into DB using pl/sql stored proc
Hi,
We have created a BPEL process in which we are taking input request and store it into Oracle Database using PL/SQL proc.
We have been unsuccessful in doing so because the data stored in table has root element missing.
Has any body done this (insert xml into DB using pl/sql stored proc) successfully ?
We can so this successfully if we do not use stored procedure and store data directly in table.
RegardsI have done this, stored it as a CLOB.
Also I received the payload as an opaque schema, so I had to convert the message from binary into string.
This way the root element doesn't get removed.
cheers
James -
How to process validations using PL/SQL function
Hi.
I created a page with a form to process DML operations against a database table. Also created a validation using PL/SQL function that returns a boolean value:
declare
v_dummy varchar2(1)
begin
select 'X'
into v_dummy
from s_customer
where id = :p2_id;
return (TRUE);
exception
when no_data_found then
return (FALSE);
when others
return (TRUE);
end;
In this case i want to send a message to the user indicating that an certain row (the one with :p2_id value) already exists in the database. The piece of code above will do the job. If this function returns true, it means the row is in the DB already.
The problem is that i don´t know what do to or how to tell htmldb that a TRUE value should issue a message or be processed as en error, whilst a FALSE means OK.
How do i tell htmldb what to do?
Suppose must do something with "expression 1" , "expression 2", etc.
Any ideas???Hóla LuÃs,
when you pick the PL/SQL function body returning a boolean, it implicitly means that TRUE means OK, while FALSE means error, always.
In order to associate such error to a given form field, you have to go back to the page definiton / validations and specify the name of the item in the corresponding field.
When you first create the validation rule, this value is not present even if you ask for the error message inline with the field.
The error message text can be specified in the validation definition, if I am not wrong.
When you need to return special error messages, including dynamic content for instance, you can use the Function Returning Error Message type, which reports an error when the string returned by the function is not null. This comes in handy when you want to display an item's code, for example, rather than generic text.
Even in this case, you must go back to the validation and specify the name of the field if you want to see it inline.
Hope it helps,
Flavio -
Can I submit pl/sql process using AJAX?
Can i submit process using ajax?
ThanksHello,
Please tell us your first name, and change your forum handle to something friendlier than user123… It’s easier for us that way.
>> Can i submit process using ajax?
The server side of AJAX allows you to invoke an APEX on-demand PL/SQL process (which is actually a PL/SQL anonymous block) or any stored procedure on the database.
The following is a good place to start understanding APEX AJAX - http://htmldb.oracle.com/pls/otn/f?p=11933:63 .
Regards,
Arie.
Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
Maybe you are looking for
-
How to design New WebUI report ?
Hi All, I want to create new reports for Service Contract orders, which should be displayed in WebUI CRM7. I am new to CRM, if anybody worked on this please let me know. Thanks in advance, Umesh
-
Encoding problem in call-back to hook URL (post parameters)
Hello all, I'm encountering a character encoding problem while retrieving the content of the shopping basket from one of our provider. After the POST request is made by the provider to our system using the hook url, when debbuging I can see that some
-
Non Blocking Socket ans Session management
All samples of Non Blocking socket use SelectionKey.attach( Object ob) to attach a partial message if the received data is incomplete. So far so good. Are we supposed to use the same approach for session management ( Keeping info on Username, passwor
-
Dbus-daemon 100% cpu usage
I'm using Bus Daemon 1.6.8 with gnome 3.6. kernel 3.6.6-1-ARCH x86_64. I find that dbus-daemon is using 100% cpu always. How can I fix this? similar problem arised in kde an year ago https://bbs.archlinux.org/viewtopic.php?id=112451
-
do the needful