Selective dequeue of messages unrelated to those already in a transaction.

Hello
In an AQ queue, I need to ensure that messages which are related to each other are processed sequentially.
For example, assume the queue is seeded with the four messages that have a business-related field called transaction reference (txn_ref) and two of the messages (1,3) belong to the same transaction (000001):
id | txn_ref |
1 | 000001 |
2 | 000002 |
3 | 000001 |
4 | 000003 |
Assume also that I am running 4 threads/processes that wish to dequeue from this queue. The following should occur:
1. thread 1 dequeues message #1
2. thread 2 dequeues message #2
3. thread 3 dequeues message #4 (because message #3 is related to #1 and #1 has not yet completed).
4. thread 4 blocks waiting for a message
5. thread 1 commits its work for message #1
6. thread 4 (or perhaps thread 1) dequeues message #3.
My initial thought was that I could achieve this with a dequeue condition where the ENQ_TIME (enqueue time) is not later than any other ENQ_TIME of all the messages that have the same TXN_REF. But my problem is how to reference the TXN_REF of a message that I have not yet selected, in order to select it. e.g.
// Java API
String condition = "ENQ_TIME = (select min(ENQ_TIME) from AQ_TABLE1 where ??"; // where what?
dequeueOption.setCondition(condition);
Is it possible to achieve what I want here?
Edited by: user8264946 on Oct 19, 2010 9:03 PM
Edited by: user8264946 on Oct 19, 2010 9:04 PM

It depends on how acceptable it is for your commit to fail. By far the easiest and safest thing to do is use Optimistic Locking. This way if the server tries to commit changes to something that has already been committed, an Optmistic Lock exception will be thrown. It's up to your application to handle this, and depending on your domain and the likelyhood of this happeneing, you could just tell the user "try again". The other option is pessemistic locking, which is very, very, dangerous (in my opinion). The main issue is that it's resource intensive, and different databases have different semantics on how it works.
IIWY, I'd look at Optimistic Locking in the docs and go from there.
- Don

Similar Messages

  • HT201272 Trying to download book from iBooks.  When I press the cloud to download, I get a ,message that I have already purchased the book, go to store, chose purchases, and select download.  I am in a continuous loop of the same message.  Any ideas?

    Purchased book from iBooks.  Went to store - purchases- chose the book to download by choosing the cloud with down arrow.  Get message that I have already purchased the book, go the store purchases to download, which is exactly what I am trying to do.  I am just in a continuous loop, but can't get the book to download.  Any ideas?

    Welcome to the Apple Community.
    You can re-download content purchased from the iBook store (availability varies depending on location) using the purchased option from the Quick Links section in the top right corner of the iTunes homepage in your iTunes application on your computer.
    You can re-download content purchased from the iBook store (availability varies depending on location) using the purchased option at the bottom of the screen after you tap the store button in the top corner of the iBook app on your iOS device.
    If the problem re-occurs, select the content which is causing a problem and use the 'Report a problem' button in Your Purchase History using your computer.

  • 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 dequeue a message from a queue

    I am able to Queue a request from a trigger. How do i dequeue this message.
    SELECT consumer_name, enq_txn_id, enq_time, enq_timestamp, user_data
    FROM AQ$PROCESSASSETS_Q;
    CONSUMER_NAME     ENQ_TXN_ID     ENQ_TIME     ENQ_TIMESTAMP     USER_DATA
    ASSET     8.5.12279     2/12/2008 4:07:36 PM     2/12/2008 4:07:36.225870 PM     (286689, 12/10/2007 8:00:00 AM, 12/16/2007 10:00:00 PM)
    ASSET     3.20.181957     2/13/2008 3:18:45 PM     2/13/2008 3:18:45.137110 PM     (286689, 12/10/2007 8:00:00 AM, 12/16/2007 11:00:00 PM)
    Thanks
    -Prasad

    Have you looked at
    DBMS_AQ.DEQUEUE(
       queue_name          IN      VARCHAR2,
       dequeue_options     IN      dequeue_options_t,
       message_properties  OUT     message_properties_t,
       payload             OUT     "type_name",
       msgid               OUT     RAW);or other functionality offered by package dbms_aq.

  • How to dequeue a message automatically by getting a notification

    If there is some data falls in the queue table.How to dequeue a message automatically by getting a notification in my application side .
    Below is the link i am following for enqueuing the message into a queue table, its happening successfully.
    http://www.oratechinfo.co.uk/aq.html
    I can see the message i enqueued in the queue table with the following query at the scheduled time. select user_data from queue_table;
    And below is the link to C++ code to dequeue the message.With the below c++ code i am able to dequeue the data manually in my application side.But i want a method to dequeue automatically by getting a notification and start to dequeue automatically.Please give me a hand and make it clear.
    http://docs.oracle.com/cd/A83908_02/NT816EE/DOC/nt.816/a99999/o4c00069.htm

    If its possible from PL/SQL side please share the code.

  • Why does my message app on my mac book pro still say I have 3 new message notifications when I already opened them a week ago?

    The message app on my mac book pro says I have 3 new message notifications and I already opened those messages a week ago. How do I get rid of the notification pop up on the app?

    Please sign out of all the messaging services you use and sign back in. If there's no change, log out or restart the computer.

  • 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

  • I keep getting "startup disk full" message even when I already moved all my files/documents to an external hard disk

    Dear all,
    What should I do? I keep getting the "startup disk full" message even when I already moved all my files and documents to an external hard disk.
    Thanks a heap.

    For information about the Other category in the Storage display, see this support article.
    Empty the Trash if you haven't already done so. If you use iPhoto, empty its internal Trash first:
    iPhoto ▹ Empty Trash
    Do the same in other applications, such as Aperture, that have an internal Trash feature. Then reboot. That will temporarily free up some space.
    According to Apple documentation, you need at least 9 GB of available space on the startup volume (as shown in the Finder Info window) for normal operation. You also need enough space left over to allow for growth of your data. There is little or no performance advantage to having more available space than the minimum Apple recommends. Available storage space that you'll never use is wasted space.
    If you're using Time Machine to back up a portable Mac, some of the free space will be used to make local snapshots, which are backup copies of files you've recently deleted. The space occupied by local snapshots is reported as available by the Finder, and should be considered as such. In the Storage display of System Information, local snapshots are shown as Backups. The snapshots are automatically deleted when they expire or when free space falls below a certain level. You ordinarily don't need to, and should not, delete local snapshots yourself.
    See this support article for some simple ways to free up storage space.
    You can more effectively use a tool such as OmniDiskSweeper (ODS) to explore your volume and find out what's taking up the space. You can also delete files with it, but don't do that unless you're sure that you know what you're deleting and that all data is safely backed up. That means you have multiple backups, not just one.
    Deleting files inside an iPhoto or Aperture library will corrupt the library. Any changes to a photo library must be made from within the application that created it. The same goes for Mail files.
    Proceed further only if the problem isn't solved by the above steps.
    ODS can't see the whole filesystem when you run it just by double-clicking; it only sees files that you have permission to read. To see everything, you have to run it as root.
    Back up all data now.
    If you have more than one user account, make sure you're logged in as an administrator. The administrator account is the one that was created automatically when you first set up the computer.
    Install ODS in the Applications folder as usual. Quit it if it's running.
    Triple-click anywhere in the line of text below on this page to select it, then copy the selected text to the Clipboard by pressing the key combination command-C:
    sudo /Applications/OmniDiskSweeper.app/Contents/MacOS/OmniDiskSweeper
    Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Paste into the Terminal window (command-V). You'll be prompted for your login password, which won't be displayed when you type it. You may get a one-time warning to be careful. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
    The application window will open, eventually showing all files in all folders, sorted by size with the largest at the top. It may take a few minutes for ODS to finish scanning your files.
    I don't recommend that you make a habit of doing this. Don't delete anything while running ODS as root. If something needs to be deleted, make sure you know what it is and how it got there, and then delete it by other, safer, means. When in doubt, leave it alone or ask for guidance.
    When you're done with ODS, quit it and also quit Terminal.

  • Error message tells me I already have an account, but when I sign in, it says I don't.

    I try to register for eprint and I get an error message saying I'm already registered. So I sign in and it says I don't. How do I register for eprint? It says I have an account, but I never registered on eprint. I guess at my password and it says they don'r recogize my email and password. I've tried like 12 times and it still doesn't work.
    This question was solved.
    View Solution.

    Do you have a Snapfish account? if so, try signing in by clicking on the Snapfish icon underneath Sign In (where it says Sign in with another account).
    If you do have a Snapfish account already, AND it still won't let you sign into ePrint with it, go to Snapfish.com login page and click "Forgot Password". This way you can reset it. Once you have reset your password, by waiting for the reset email, then try logging in to ePrint center again by using the Snapfish login.
    If I have helped in any way, just click the Kudos star on the left. Also, if your issue has been resolved, don't forget to select Accept as Solution

  • Is there anyway to change/add more highlighter colors in Preview? I need more colors aside from those already provided in the app.

    I'm a law student and I use the preview app extensively for reading cases. I need more highlighter colors aside from those already provided and it seems that there's no possible way of adding/changing the colors.

    Unlike Preview, the Adobe Reader application allows you to change PDF highlight (comment) text colors via a standard Apple color chooser. Click Tools on the Reader Toolbar, and then Comment. The second button in the Comment Annotation section is highlight text, and defaults to canary yellow.
    Highlight the document text, and then two-finger tap/control-right-click that highlighted text. On the contextual menu, you will see Properties…. The properties panel has a color well set to yellow. Click this color well, and a standard Apple color chooser will appear that allows you more creative control over your highlight color. When you click a color in the color chooser, it is not automatically updated in the color well, which remains dark grey. When you quit the color chooser, the selected color is updated in this color well and in your document. The next text that you select to highlight will receive a default yellow highlight.

  • I´m getting the following message: Email address is already verified for another Apple ID.

    When trying to add a new account I´m getting this error message: Email address is already verified for another Apple ID.
    I didn´t know I have another Apple ID. How can I find out which Apple ID is that one and how can I add this email address to the Apple ID I currently use? Thanks

    Are you sure you don't have another ID? If you purchased Apple hardware you may very well have been given an ID as part of the registration process. You can check this by going to http://appleid.apple.com and clicking 'Find My Apple ID'. Follow the instructions and it should list any IDs you have.
    However once an address has been associated with an Apple ID you can't use it with another (even if it's removed from the first) so you are probably going to have to use another address, such as a free one from Yahoo or GMail.

  • When I try to start Firefox, I get a message that it is already running but not responding and I can't run another Firefox at the same time. I uninstalled and reinstalled. No change. Tried various other suggestions. Help!!

    When I try to start Firefox, I get a message that it is already running, but not responding and that I should close it before trying to run another Firefox. But I cannot find a way to close Firefox program that is not running as far as I can see. I tried uninstalling and reinstalling Firefox, but that did not work. I've tried various other things, but no luck. I thought programs should stop when the computer is turned off, but that didn't work either.

    How are you opening the Profile Manager?
    *http://kb.mozillazine.org/Profile_Manager
    Sounds that Firefox is still or already running.<br />
    See:
    *http://kb.mozillazine.org/Kill_application

  • When I use a GSI external antenna for WiFi I first get a message that "Firefox is already running but not responding etc", and then Firefox crashes. Can anyone help please?

    Because of weak WiFi signal I need to use an external antenna (GSI USB wireless WIFI long range network adapter). My computer can see the signal clearly and shows that I am connected to the right network. But when I try to launch Firefox I get a message that "Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system." When I click "OK" Firefox tries to load websites but gives up and reports "Problem Loading". It looks like Firefox is having trouble "seeing" the signal from the external antenna. What do I need to do please?

    Try Ubuntu support, I don't think your problem is with Firefox - it will use the connection that the Operating System "makes". I'm a real noob with Ubuntu myself, and don't think I can help you figure out the problem.
    http://ubuntuforums.org/

  • When I try to open Firefox I get a message saying it is already open. However it is not open and i cannot access Firefox

    When I try to open Firefox I get a message saying it is already open. However it is not open and i cannot access Firefox

    See:
    * http://kb.mozillazine.org/Recovering_a_missing_profile
    * http://kb.mozillazine.org/Profile_in_use
    * https://support.mozilla.com/kb/Firefox+is+already+running+but+is+not+responding
    If it happens after you've closed Firefox and want to restart the see these:
    See "Hang at exit":
    *http://kb.mozillazine.org/Firefox_hangs
    See "Firefox hangs when you quit it":
    *https://support.mozilla.com/kb/Firefox+hangs

  • I can no longer open firefox. I get a message that it is already open but when I try to force quit the app it is not there.

    I am running IMacs with an OS10.6x operating system. This problem has occurred on several of my machines now. I can still open firefox from alternate profiles on the same machine, but the student profile will give me the message that it is already open and can only have one instance running at a time.

    Make sure that the profile that Firefox wants to use and that is specified in profiles.ini still exists. If that profile isn't found then you get that same error message.
    See:
    * http://kb.mozillazine.org/Recovering_a_missing_profile
    * http://kb.mozillazine.org/Profile_in_use

Maybe you are looking for

  • Question to Z10 apps

    Hello, I´m new here (and from Germany) and I have questions. Actually I have an Android Smartphone, but I want to change to BB and I want to buy a Z10. How is the situation about apps? I ask for a compass (in Android i. e. part of the "Swiss Army Kni

  • 'Back ground Job' Out put is truncating

    Hi Gurus,                   I am excecuting the report in background. It's out put is truncating after some length and comes in the next line. It gives the undesirable fromat. I tried with higher spools also. it doesn't do the need.                  

  • Page number problem while printing

    We are unable to get the page number while printing from SAP, we are trying to print a word document from SAP and when it prints the page numbers do not appear properly. if we save the document to the desktop and print, it prints properly. We print t

  • I cannot open my Gmail messages in Firefox except when I answer. Internet Explorer does work. How can I solve this.

    This started a couple of days ago with my wife's gmail account while I could still read my messages. Today I cannot read them either and we have not changed anything in settings.

  • Medical office management software

    Hi everyone.  I'm a little new here and I'm in need of studying TSQL. I have used it in the past, but it's been many years, and I barely touched on it. Mostly for simple things for an old project I did in the 90's.  Anyway, I'm trying to help a frien