Dequeuing multiples messages in a PLSQL CallBack

Hi all:
I would like to dequeue multiples messages in a PLSQL CallBack for performance reason.
Everything works fine, but I see that Oracle AQ sent the rest of the notifications messages to the callback independent of an empty queue.
I added a table lock to prevent parallel execution of the Call Back, but when this resource lock is freed, many oracle processes are started in parallel to process the rest of the notification pending.
Here my Call Back:
  static procedure msgCallBack(context  IN  RAW,
                               reginfo  IN  SYS.AQ$_REG_INFO,
                               descr    IN  SYS.AQ$_DESCRIPTOR,
                               payload  IN  RAW,
                               payloadl IN  NUMBER) is
    dequeue_options     dbms_aq.dequeue_options_t;
    message_properties  dbms_aq.message_properties_t;
    message_handle      RAW(16);
    message             lucene_msg_typ;
    prefix              VARCHAR2(4000) := utl_raw.cast_to_varchar2(context);
    rcount              NUMBER;
    begin
      EXECUTE IMMEDIATE 'LOCK TABLE '||prefix||'$T IN EXCLUSIVE MODE';
      EXECUTE IMMEDIATE 'select count(*) from '||prefix||'$QT' INTO rcount;
      if (rcount >0) then
        sync(prefix); -- dequeue all messages
      end if;
      commit;
  end msgCallBack;
sync(prefix) dequeues all messages pending on the queue, if statement is to avoid non-necessary call to sync procedure on an empty queue.
Is there any way to clean up all pending notification inside a Call Back?
I'll appreciate any help on this topic.
Best regards, Marcelo.

Hi Marcelo,
If you do a dequeue with dequeue_options.wait=dbms_aq.forever it will wait until the message is enqueued. It is not consuming (much) cpu-time. AQ solves this under water for you by polling the queue-table.
If you schedule this job with an interval of say 10secs (using dbms_job or dbms_scheduler) the job will come up after database startup. The only other option is to start the process using a sqlplus or similar tool. But since the dequeueu will wait for the next incomming message the sqlplus session will halt. Using the jobscheduler in the database causes the job to be run in a session with in the database (so you get your session freed) and after a database restart, the job will come up.
You can use this with a normal default queue. You should not use the dequeue_option visibility=dbms_aq.immediate, because then you loose your "transactional grouping".
I'd advise to either
. not use wait=dbms_aq.forever, but a reasonable amount of wait time and then let your job run to complete. Then the job scheduler can reschedule the process in an interval of for example 1 - 10 sec.
. do use wait=dbms_aq.forever but define a kind of "suicide pill". That is a message that you give a special meaning for example a correlation-id with a special text, and the highest possible priority. You have to make sure that it by passes every other message-priority. If the process gets this message it has to stop.
The reason I advise eiter of them is that you want a means of stopping the process in a neat fashion. For example for maintenance purposes. I personally have a slight prefrence for the first option, because when you remove the job from the jobscheduler you may trust that the job stops. For the second option you have to rely on the process receiving and consuming the suicide pill. But it is manner of taste: the second option is also a good way. The first option introduces a possible latency since the job is regularly not executing for a few seconds. The second gives the best response I think.
Regards,
Martien

Similar Messages

  • Plsql callback (dbms_aq.register) stops working

    we had, for quite a while, a working situation where a incoming message notifies a plsql procedure, which dequeues and handles the message, resulting in a response message in a different queue
    the queue has one subscriber and through dbms_aq.register I registered a plsql callback and all worked fine for about a year
    suddenly this stopped working - messages aren't dequeued anymore - for no apparent reason (nothing changed in this part of the database)
    I already dropped and recreated the queue table, queues, subscriptions and registered the plsql callback again, but no results
    does anyone have a clue where to look (specific sys tables/views, database parameters etc) because I am running out of ideas...
    we are running the 10.2.0.1.0 database
    greatings
    Jan

    Jan,
    The EMNO (Event Monitor) process is responsible to execute the AQ notifications, in this case your pl/sql callback. This may or may not be your problem. I'm not sure how much help this link will be but it covers Event Monitor issues for various versions of Oracle. https://metalink.oracle.com/metalink/plsql/f?p=130:14:2721106654994549115::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,105067.1,1,1,1,helvetica
    Jason

  • Dequeuing the message using Non Sys user

    Hi all,
    I've implemented Advanced Queuing in one Schema(Say "temp") which has AQ privileges. My requirement is Asynchronous Communication between two programs.
    In One program i've DBMS_AQ.ENQUEUE to put the message onto the queue. The user "temp" enqueued the message.
    I've a anonymous PL/SQL callback procedure registered to dequeue the message. but while dequeuing the message, the user is "SYS". Immediately after dequeuing the message, i've a call to the second program which uses some views. In my application we have dba policies applied to these views. So only temp user can access those views where SYS user doesnt have any access to these views.
    we already have one solution i.e., giving access to SYS user also but this will result in some other security concerns for the application
    Another solution could be dequeuing the message with "temp" user (NON sys user).
    So i would like to know whether it is possible to dequeue the message with NON-SYS user ? i've tried searching the dequeue options and message properties but couldn't get anything..
    can anyone help me in solving this problem??

    Hi paul,
    Thanks for the response :). I've tried this already but still the dequeue user id "SYS". i'll explain you in detail with the code.
    I've create queue table and queue with the following code :
    create or replace TYPE temp_msg_type as object (seq_no NUMBER(10),
    req_type varchar2(6))
    begin
    dbms_aqadm.create_queue_table(
    queue_table => 'test_queue_tab',
    queue_payload_type => 'temp_msg_type',
    multiple_consumers => true);
    dbms_aqadm.create_queue(
    queue_name => 'test_queue',
    queue_table => 'test_queue_tab');
    dbms_aqadm.start_queue(
    queue_name => 'test_queue');
    end;
    After this an Agent is subscribed to this queue.
    begin
    dbms_aqadm.add_subscriber(
    queue_name => 'test_queue',
    subscriber => sys.aq$_agent('recipient', null, null));
    end;
    Then registered an PL/SQL callback procedure to this queue.
    begin
    dbms_aq.register(aq$_reg_info_list(
    aq$_reg_info('test_queue:RECIPIENT',
    DBMS_aq.NAMESPACE_AQ,
    'plsql://notifyCB_prd',
    HEXTORAW('FF')) ) ,
    1);
    end;
    The follwing procedure will enqueue the message. in the below code before i enqueue it i am inserting the current sessions' user, it got printed as "SCOTT".
    create or replace procedure enqueue_msg_prd( O_status_code IN OUT varchar2 )
    as
    enqueue_options dbms_aq.enqueue_options_t;
    message_properties dbms_aq.message_properties_t;
    message_handle RAW(16);
    message temp_msg_type;
    begin
    --enqueue_options.visibility := DBMS_AQ.IMMEDIATE;
    message := temp_msg_type(112, user);
    O_status_code := 'S';
    dbms_aq.enqueue(queue_name => 'test_queue',
    enqueue_options => enqueue_options,
    message_properties => message_properties,
    payload => message,
    msgid => message_handle);
    end;
    The following procedure will dequeue the message. this procedure will be automatically triggered when i commit the enqueue transaction since there is anonymous callback procedure registered for this queue. In the below code after i dequeue it i am inserting the sessions' user, it got printed as "SYS".
    create or replace
    procedure notifyCB_prd( context raw,
    reginfo aq$_reg_info,
    descr aq$_descriptor,
    payload raw,
    payloadl number)
    as
    dequeue_options dbms_aq.dequeue_options_t;
    message_properties dbms_aq.message_properties_t;
    message_handle raw(16);
    message temp_msg_type;
    begin
    dequeue_options.msgid := descr.msg_id;
    dequeue_options.consumer_name := descr.consumer_name;
    --execute immediate 'conn  session set current_user= scott';
    DBMS_AQ.DEQUEUE(
    queue_name => descr.queue_name,
    dequeue_options => dequeue_options,
    message_properties => message_properties,
    payload => message,
    msgid => message_handle);
    insert into temp values(message.seq_no,user);
    commit;
    end;
    Even i queried the aq$test_queue_Tab view. in this view, value in deq_user_id is "SYSS"
    is there any way to get the users session as 'SCOTT' ??

  • How to show multiple messages for a single exception

    hi
    Please consider this example application created using JDeveloper 11.1.1.3.0
    at http://www.consideringred.com/files/oracle/2010/MultipleMessagesExceptionApp-v0.01.zip
    It has a class extending DCErrorHandlerImpl configured as ErrorHandlerClass in DataBindings.cpx .
    Running the page and entering a value starting with "err" will result in an exception being thrown and multiple messages shown.
    See the screencast at http://screencast.com/t/zOmEOzP4jmQ
    To get multiple messages for a single exception the MyDCErrorHandler class is implemented like
    public class MyDCErrorHandler
      extends DCErrorHandlerImpl
      public MyDCErrorHandler()
        super(true);
      @Override
      public void reportException(DCBindingContainer pDCBindingContainer,
        Exception pException)
        if (pException instanceof JboException)
          Throwable vCause = pException.getCause();
          if (vCause instanceof MyMultiMessageException)
            reportMyMultiMessageException(pDCBindingContainer,
              (MyMultiMessageException)vCause);
            return;
        super.reportException(pDCBindingContainer, pException);
      public void reportMyMultiMessageException(DCBindingContainer pDCBindingContainer,
        MyMultiMessageException pException)
        String vMessage = pException.getMessage();
        reportException(pDCBindingContainer, new Exception(vMessage));
        List<String> vMessages = pException.getMessages();
        for (String vOneMessage : vMessages)
          reportException(pDCBindingContainer, new Exception(vOneMessage));
    }I wonder if calling reportException() multiple times is really the way to go here?
    question:
    - (q1) What would be the preferred use of the DCErrorHandlerImpl API to show multiple messages for a single exception?
    many thanks
    Jan Vervecken

    fyi
    Looks like using MultipleMessagesExceptionApp-v0.01.zip in JDeveloper 11.1.1.2.0 (11.1.1.2.36.55.36) results in a different behaviour compared to when used in JDeveloper 11.1.1.3.0 (11.1.1.3.37.56.60)
    see http://www.consideringred.com/files/oracle/img/2010/MultipleMessages-111130versus111120.png
    When using JDeveloper 11.1.1.2.0 each exception seems to result in two messages where there is only one message (as intended/expected) per exception when using JDeveloper 11.1.1.3.0 .
    (Could be somehow related to the question in forum thread "multiple callbacks to DCErrorHandlerImpl".)
    But, question (q1) remains and is still about JDeveloper 11.1.1.3.0 .
    regards
    Jan

  • AQ Propagation Notifications/PLSQL Callback Query?

    I have the following scenario working but have a question:
    I have two databases, I Enqueue a message onto a Queue in Database 1 and scheduling Propagation to a Queue in Database 2.
    In Database 2 the queue has a PL/SQL procedure registered (using DBMS_AQ.Register) so that as the propagated message arrives it calls the procedure which dequeues it and saves the message to the Table.
    It is all working fine, except that the Dequeue process on Database 2 seems to get invoke after approx 5 mins after it is Enqueued. SO you can see the message on the Subscribing Queue with an Enqueue Time, and it seems to always be about 5 mins later till the procedure is kicked off to dequeue it.
    How do you set the time that it takes to dequeue the message?
    There are no parameters on the DBMS_AQ_Register proc to set this.
    I can't find anything in the docs?
    I originally had a demo setup using PL/SQL callback on a local Queue (without propagation between two Databases) and the Dequeue was virtually instantaneous?
    Regards
    Stuart

    Hello,
    jobqueue_interval is not unsupported it is just hidden. In most cases the default is enough which is why it is hidden. As I recall the default is 5 seconds in 10.2 so it does not explain the 5 minute delay you are seeing. AQ only ever uses 1/2 the available job_queue_processes so if only 1 is available I would be surprised if it worked at all. Have you increased the number to 10?
    There are no other ways to tune notification callbacks in any available version of Oracle that I am aware of.
    Thanks
    Peter

  • How do you select multiple messages/conversations on SMS/MMS to forward or save to memory card on Samsung Stratosphere?

    How do you select multiple messages/conversations on SMS/MMS to forward or save to memory card on Samsung Stratosphere? 
    My screen is cracked and I need to replace my phone and I don't see a way of selecting multiple messages or even conversations one at a time to forward them to email or to save them to a memory card.  I can delete thread but can't forward it or move it.  Is there a setting somewhere that will move the storage location for messages to the memory card instead of internal?
    If not, any suggestions on backup apps?  I have heard of Txtract to back up SMS and MMS messages, and Titanium Backup to back up everything (SMS, MMS, apps, app data...).  Anyone have any experience with those, or other suggestions?
    Thanks!
    Rich

    <Duplicate topic.  This thread will be locked.  Please see Help transferring data (SMS, MMS, Apps, App data) to new phone? for any replies.>

  • Adapter file sender doesn't split file into multiple message

    Hi everybody.
    We are in PI 7.0 SP10.
    In adapter file sender, I want to split a file into multiple file.
    We use protocole "file content conversion"
    in the field "recordset per message", I put the value 10 to test.
    The file content 30 records .
    The result we have is the treatment is not split into multiple message .
    The treatment is made but with one message.
    I need  to treat big files.
    Is there some one who have an idea  why t doesn't work ?
    Thanks in advance for your help.
    Regards
    Edited by: Eric  KOralewski on Jun 25, 2009 3:14 PM

    Hi,
    have you specified recordset name......if not, then specify it.............
    in recordset structure, specify like RECORD,1 and not RECORD,*
    again test your scenario......if still your file data is not getting split, then ask your basis guys to do a full CPACache refresh using PIDIRUSER..........your basis guys will know how to do it..........then again test your scneario............
    Regards,
    Rajeev Gupta

  • Cannot select multiple messages in a sequence diagram

    In sequence diagrams, deleting multiple messages is tedious because multiple messages cannot be selected by using a selection rectangle.
    1) If the rectangle contains a single message, its object is also highlighted. So when multiple messages are selected, the corresponding objects are selected.
    2) If the selection rectangle overlaps a single line of the combined fragments box, the entire box is selected.
    I could same time if Studio used normal CTRL conventions. In other applications, holding down CTRL has two possible results.
    1) If the item to be selected is not highlighted, then that item becomes highlighted and is added to the selection group. Studio does this.
    2) If the item to be selected is already highlighted, then that item becomes non-highlighted and is removed from the selection group. Studio does not do this. So I cannot use a selection rectangle, then selectively use CTRL to remove unwanted items from the selection.
    Can anyone suggest a way of selecting multiple messages?
    As a side issue, does anyone know how to remove individual items from a selection?

    TreySpiva wrote:
    Have you tried using the Shift key when selecting?It's the same problem. Selecting one or more messages also highlights the sending and receiving objects associated with the messages. Pressing DELETE at this point would also delete the objects.

  • Multiple message threads from same person

    I have multiple message threads from the same person in messages on my iPhone and iPad. One comes from their phone number and one from their email. Here are all the details, I would love to be able to combine them into one thread.
    This other person and myself each have a new MacBook Pro, iPad Air 2, I have an iPhone 6 and they have an iPhone 5S. They are all updated with the most recent system software.
    On my MacBook Pro, the conversations that are split on my iPhone and iPad are not split. On the MacBook Pro, all of the texts from both conversations are appearing in one. In my contacts which are syncing with iCloud I have both the phone number and email address of this other person.
    I have messages set up on all of my devices to send and receive from my phone number and my email, start new conversations is from my phone number. This other person has it set up the exact same way on all of their devices.
    So why when I text this person from one conversation thread and they respond it comes through to the other conversation thread?
    Why can't I seem to join these two conversations when everything is set up the way it should be and they ARE joined on my MacBook Pro but not my iPhone and iPad?

    She kept the same number on her new phone, but now there are 2 conversation threads. A new one started with messages sent from the new phone, the old phone should be out of service now. Why didn''t  messages sent by the new phone resume in the same conversation? I assume because it's a different IMEI.  But now whenever I use her  phone number to create a new message, it goes in the old IMEI*'s conversation thread and is therefore not delivered. It's in green so it thinks it's an SMS also not a iMessage device.
    If I want to send a message correctly  to the new phone, I have to make sure I  go into the correct newer thread and enter it there,
    For your second answer, the person is receiving the message but the thread now says "email address", not the person's name in the contact list. The sender is sending to the person's phone number, not her email address.

  • In Earthlink Webmail, the "check all" and "delete" button for deleting multiple messages no longer function (although they work in I explorer).

    When using the webmail application for earthlink email, the "check all" option to select an entire page of messages at once no longer functions. Same problem with the "delete" buttons that are located at the top and bottom of the page with multiple messages. Consequently, the only way to delete a message is to open the message and delete it in that view -- extremely tedious if there are a lot of messages.
    This is a recent change, in the last few days. Everything works fine in I explorer. Earthlink support suggested I start Firefox in safe mode and restore firefox default settings. I went through the process on the help page. It didn't help.
    I'll provide the earthlink link, but it is my email page that is the problem.

    Same here.
    - select multiple mails with the SEARCH option (manually selecting seems to work fine)
    - click the move button
    - list of folders appears (witn account &amp; cancel options that both still work)
    - click on a folder
    - mail flies to this folder (animated)
    - list of folders remains visible
    - the cancel button does NOT work
    - the accounts button takes you back to the root "directory" of your accounts
    - in my case "live" and "exchange"
    - this screen is a dead end. Clicking on both the account names and the cancel button do not work
    A complete restart fixes the problem

  • Processing of multiple messages Using BPM

    Hello everybody,
    I am pretty much a newbie to this XI technology. I am currently testing a File to File scenario Concerning BPM. The source file contains multiple messages in an XML structure. How can each of these XML messages be posted as individual files? I have reffered to this <a href="/people/narendra.jain/blog/2005/12/30/various-multi-mappings-and-optimizing-their-implementation-in-integration-processes-bpm-in-xi on BPM as a guideline; but here the number of messages are restricted and I want to dynamically determine how many messages are contained in the XML file. Anybody has any idea how to achieve this?
    Thanks and Warm Regards,

    Hello,
    The blog you mentioned is for cutting one file into 2 files.
    I think you need to use the "<b>ParForEach</b>" step in the BPM. This step is used to loop on a multiple line message and create a single message in one branch. Then you can add a send step in this branch and end only one message.
    <u>See the Flight Demo :</u>
    http://help.sap.com/saphelp_nw04/helpdata/en/5a/cede3fc6c6ec06e10000000a1550b0/frameset.htm
    <u>Object in IR :</u>
    BASIS -> http://sap.com/xi/XI/Demo/Agency -> BPM -> MultipleFlightBookingCoordination
    Regards,
    Chris

  • Multiple message through FIle Adapter using XI 2.0

    I have scenario to create multiple message using File adapter .My file structure will be like
    EMPID     NAME     SKILLS
    001     A      ABAP
    001     A      XI
    002     B      JAVA
    Now I want to post first 2 records in one message and last record in other message.
    Can we do it in XI 2.0.Any help appreciated

    Hi Suraj.
    Thank you very mutch for your reply.
    Excuse me...my mapping is done for message type and idoc.
    My problem is that when the interface start, on the sxmb_moni I see an error like this:
    Creating Java mapping com.sap.xi.tf._MM_XmlOrderToIdocMapping_ --- Using MappingResolver with context URL //srvsapdev/sapmnt/CX1/SYS/global/xi/mapping/gestione_magazzini/7fa9c9e15a7811dab710f3e3ac10826e/ --- Load of com/sap/xi/tf/_MM_XmlOrderToIdocMapping_.class from //srvsapdev/sapmnt/CX1/SYS/global/xi/mapping/gestione_magazzini/7fa9c9e15a7811dab710f3e3ac10826e failed. --- Class not found: com.sap.xi.tf._MM_XmlOrderToIdocMapping_ --- java.lang.ClassNotFoundException at RUMappingJava.load(): Could not load class: com.sap.xi.tf._MM_XmlOrderToIdocMapping_ Class not found: com.sap.xi.tf._MM_XmlOrderToIdocMapping_ --- com.sap.aii.ibrun.server.map.MappingRuntimeException: at com.sap.aii.ibrun.server.map.MappingRuntimeException.code_STYLESHEET_OR_CLASS_NOT_FOUND
    ..where 'gestione_magazzini' is my namespace and 'MM_XmlOrderToIdocMapping' is my message mapping.
    Can you help me to undestand the problem?
    Thanks,
    Gianluca

  • ESB/File Adapter - XML files containing multiple messages

    Hi,
    In all the examples on file adapters I read, if files contain multiple messages, it always concerns non-XML files, such as CSV files.
    In our case, we have an XML file containing multiple messages, which we want to process separately (not in a batch). We selected "Files contain Multiple Messages" and set "Publish Messages in Batches of" to 1.
    However, the OC4J log files show the following error:
    ORABPEL-12505
    Payload Record Element is not DOM source.
    The Resource Adapter sent a Message to the Adapter Framework which could not be converted to a org.w3c.dom.Element.
    Anyone knows whether it's possible to do this for XML files?
    Regards, Ronald

    Maybe I need to give a little bit more background info.
    Ideally, one would only read/pick-up small XML documents in which every XML document forms a single message. In that way they can be processed individually.
    However, in our case an external party supplies multiple messages in a single batch-file, which is in XML format. I want to "work" on individual messages as soon as possible and not put a huge batch file through our ESB and BPEL processes. Unfortunately we can not influence the way the XML file is supplied, since we are not the only subscriber to it.
    So yes, we can use XPath to extract all individual messages from the XML batch-file and start a ESB process instance for each individual message. But that would require the creation of another ESB or BPEL process which only task is to "chop up" the batch file and start the original ESB process for each message.
    I was hoping that the batch option in the File adapter could also do this for XML content and not only for e.g. CSV content. That way it will not require an additional process and manual coding.
    Can anyone confirm this is not supported in ESB?
    Regards,
    Ronald
    Message was edited by:
    Ronald van Luttikhuizen

  • How to transmit multiple messages over CAN

    Hi All,
    How to transmit multiple messages over CAN ? With all three messages i want to send the system time & date also.
    How can i get the timestamp in DBL format (Since the timestamp in the input of ncWriteNetMult.vi is a DBL). If possible kindly share the code in Labview 7.1 also.
    Thanks in advance.
    J

    The NI-CAN driver brings examples for nearly every use case. Driver version 2.4 or later has the Write multiple function to write multiple frames at ones.
    There is an example available for LabVIEW, CVI and VC/VBasic called CAN Transmit multiple.
    Also check the attached VI and the Can manual: http://www.ni.com/pdf/manuals/370289m.pdf
    What do you mean by converting Timestamp to DBL? Timestamp contains all date and time information. You can convert it into string format as shown below and then use the relevant data from it by string operations.
    Hope this solves your problem.
    Shreyas Hebbare
    Shreyas Technologies
    India
    Attachments:
    Transmit Multipe Objects at Different Rates_LV80.vi ‏36 KB

  • Sender Proxy to send multiple messages

    Hello All XI experts,
    I need your help to work for my scenario which is a Proxy-File .
    I need to send data picked up from certain group of tables via sender proxy to XI.
    The problem is that , we will be having thousands of records at the same time , so what we plan we can send the records via multiple messages in bunch of n no of messages rather sending the entire data in a single message.
    Can you please help me in order to find a way by which we can achieve this in sender proxy ( to send multiple messages with each bunch having n no of messages  ) .
    Waiting for your expert thoughts and invaluable help.
    Thanks,
    Sunil

    Hi
    This scenario can be handled at abap end.
    Decide the number of records you want to send in one file. In abap when the number of records reached then call the abap proxy method. For the remaining records again call the abap proxy method so while going to XI it will pass only the number of records desired by you.

Maybe you are looking for