Dbms_aqadm.add_subscriber

Assume I have a stored procedure, myproc, owned by user1 that executes add_subsciber to add a subscriber to q1.
User1 has dbms_aqadm grants.
I issue grants on myproc to user2, but get the following when user2 executes the procedure:
ORA-01031: insufficient privileges
ORA-06512: at "SYS.DBMS_AQADM_SYS", line 4471
ORA-06512: at "SYS.DBMS_AQADM", line 387
Must user2 be granted aqadm to open a subscrption? This seems like more of a user type action as opposed to administrative. We would rather not grant admin for a user to create a subscription to a queue.
Thanks,
Eric

To be more specifice, it appears a user must be granted "manage any queue" system privilege to create a subscription in PL/SQL.
Is this correct? We wish to allow a user to create a subscription to only a single queue where the queie is in another user's schema.

Similar Messages

  • Dbms_aqadm hang while calling add_subscriber can i make a asynchronous call

    Hi ,
    I call dbms_aqadm.add_subscriber but it hangs ( most probbably for the reason that some process has the lock on the queue - my guess ,correct me if wrong).
    Can i make the call add_subscriber asynchronous which is returning some error code or something specifying that unable to add subscribe due to the following reason.
    Please reply immeaditely.
    Thanks
    Saurabh

    Hi line123,
    Sorry about all the issues you've had getting this installed. I've alerted your local area market about what's going on. They will get in contact with you about coming out to get this resolved. 
    Thank You

  • Can't Seem to Get my Event Based Job To Execute

    What makes this slightly different than other posts on this topic is that we want to use our own queue/payload object rather than the built-in SCHEDULER$_EVENT_QUEUE. There are many reasons for this. What follows in under 11gR2 (11.2.0.3)
    So, the following code blocks are just for a proof of concept piece intended to create a simple job and to have it fired based on the arrival of a message in a queue. (Something we have a requirement to do) The issue that I just can't seem to resolve is that, for some reason, the scheduler object never triggers the job. I can't find any trace or alert log entries to help me diagnose. What I do know is that the queue itself is fine (dequeues and enqueues work normally). The object payload type is fine (All of these tested from the EVENT_JOB_MGR package provided below).
    Here's the PL/SQL Type that is the payload object of the queue and is also referenced in the package:
    CREATE OR REPLACE TYPE RUN_MSG AS OBJECT
      STATUS VARCHAR2(255)
    Here are the queue and queue table:
    BEGIN
      DBMS_AQADM.CREATE_QUEUE_TABLE
        QUEUE_TABLE           =>        'JUPSHAW.EVENT_JOB_QT'
       ,QUEUE_PAYLOAD_TYPE    =>        'JUPSHAW.RUN_MSG'
       ,COMPATIBLE            =>        '10.0.0'
       ,STORAGE_CLAUSE        =>        '
                                         TABLESPACE RISKDM_DATA'
       ,SORT_LIST             =>        'ENQ_TIME'
       ,MULTIPLE_CONSUMERS    =>         TRUE
       ,MESSAGE_GROUPING      =>         0
       ,SECURE                =>         FALSE
    End;
    BEGIN
      DBMS_AQADM.CREATE_QUEUE
        QUEUE_NAME          =>   'JUPSHAW.EVENT_JOB_Q'
       ,QUEUE_TABLE         =>   'JUPSHAW.EVENT_JOB_QT'
       ,QUEUE_TYPE          =>   SYS.DBMS_AQADM.NORMAL_QUEUE
       ,MAX_RETRIES         =>   0
       ,RETRY_DELAY         =>   0
       ,RETENTION_TIME      =>   -1
    END;
    DECLARE
      aSubscriber sys.aq$_agent;
    BEGIN
      aSubscriber := sys.aq$_agent('SCHEDULER$_EVENT_AGENT',
                                  0);
      dbms_aqadm.add_subscriber
         ( queue_name     => 'EVENT_JOB_Q'
          ,subscriber     => aSubscriber);
    END;
    BEGIN
      SYS.DBMS_AQADM.START_QUEUE
        QUEUE_NAME => 'JUPSHAW.EVENT_JOB_Q'
       ,ENQUEUE => TRUE
       ,DEQUEUE => TRUE
    END;
    (I think the scheduler automatically added itself as a subscriber (see above) after the queue itself was created)
    So, here's the simple package:
    CREATE OR REPLACE PACKAGE EVENT_JOB_MGR
    AS
        PROCEDURE DEQUEUE_JOB_STATUS_MSG;
        PROCEDURE ENQUEUE_JOB_STATUS_MSG;
        PROCEDURE RECORD_DEQUEUED_STATUS( a_RunMsg  RUN_MSG );
    END EVENT_JOB_MGR;
    CREATE OR REPLACE PACKAGE BODY EVENT_JOB_MGR
    AS
        PROCEDURE RECORD_DEQUEUED_STATUS( a_RunMsg  RUN_MSG )
        IS
            ls_Status       VARCHAR2(32);
        BEGIN
            ls_Status := a_RunMsg.STATUS;
            INSERT INTO DEQUEUE_RECORD
            ( STATUS )
            VALUES
            ( ls_Status );
            COMMIT;    
        END;       
        PROCEDURE DEQUEUE_JOB_STATUS_MSG
        IS
            l_DeQOptions    DBMS_AQ.DEQUEUE_OPTIONS_T;
            l_MsgProps      DBMS_AQ.MESSAGE_PROPERTIES_T;
            l_DeQMsgID      RAW(16);
            l_RunMsg        RUN_MSG;                
        BEGIN
            l_DeQOptions.CONSUMER_NAME := 'EVENT_JOB';
            DBMS_AQ.DEQUEUE(    queue_name          =>  'EVENT_JOB_Q',
                                  dequeue_options     =>  l_DeQOptions,
                                  message_properties  =>  l_MsgProps,
                                  payload             =>  l_RunMsg,
                                  msgid               =>  l_DeQMsgID );
            COMMIT;                             
            RECORD_DEQUEUED_STATUS( l_RunMsg );                              
        END;
        PROCEDURE ENQUEUE_JOB_STATUS_MSG
        IS
            l_EnQOptions    DBMS_AQ.ENQUEUE_OPTIONS_T;
            l_MsgProps      DBMS_AQ.MESSAGE_PROPERTIES_T;
            l_EnQMsgID      RAW(16);
            l_RunMsg        RUN_MSG;               
        BEGIN   
            l_RunMsg := RUN_MSG('Success');
            DBMS_AQ.ENQUEUE(  QUEUE_NAME          =>  'EVENT_JOB_Q',
                                ENQUEUE_OPTIONS     =>  l_EnQOptions,
                                MESSAGE_PROPERTIES  =>  l_MsgProps,
                                PAYLOAD             =>  l_RunMsg,
                                MSGID               =>  l_EnQMsgID);
        END;
    END EVENT_JOB_MGR;
    -- Finally the program, schedule and job
    BEGIN
        DBMS_SCHEDULER.CREATE_PROGRAM(
            PROGRAM_NAME          => 'EVENT_JOB_PROG',
            PROGRAM_ACTION        => 'EVENT_JOB_MGR.RECORD_DEQUEUED_STATUS',
            PROGRAM_TYPE          => 'STORED_PROCEDURE',
            NUMBER_OF_ARGUMENTS   => 1,
            ENABLED               => FALSE );
        DBMS_SCHEDULER.DEFINE_METADATA_ARGUMENT (
            program_name        => 'EVENT_JOB_PROG',
            argument_position   => 1,
            metadata_attribute  => 'EVENT_MESSAGE' );  
        DBMS_SCHEDULER.ENABLE( NAME => 'EVENT_JOB_PROG');        
    EXCEPTION
      WHEN OTHERS THEN RAISE ;       
    END;
    COMMIT
    BEGIN
      DBMS_SCHEDULER.CREATE_EVENT_SCHEDULE (
       schedule_name     =>  'EVENT_JOB_SCHED',
       start_date        =>  SYSTIMESTAMP,
       event_condition   =>  'TAB.USER_DATA.STATUS = ''SUCCESS''',
       queue_spec        =>  'EVENT_JOB_Q');
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_JOB (
       job_name            =>  'EVENT_JOB',
       program_name        =>  'EVENT_JOB_PROG',
       schedule_name       =>  'EVENT_JOB_SCHED',
       enabled             =>  TRUE,
       comments            =>  'Start if you get a success message');
    END;
    I call the ENQUEUE_JOB_STATUS_MSG method to stick a message on the queue. I can confirm that it can be dequeued and logged using the DEQUEUE_JOB_STATUS_MSG method in the package. However, nothing seems to happen (at all) as far as the scheduler job when a message is put on the queue. I am thinking it should dequeue the message with status set to SUCCESS and then, kick off the job.
    Can anyone see why the above wouldn't work? Been stuck here for a couple of days.
    Thanks,
    -Joe

    Try to create job that react on event directly not using schedule.
    BEGIN
        dbms_scheduler.create_job(job_name => 'EVENT_JOB',
                                  program_name =>  'EVENT_JOB_PROG',
                                  event_condition => 'TAB.USER_DATA.STATUS = ''SUCCESS''',
                                  queue_spec => 'EVENT_JOB_Q',
                                  enabled => true,
                                  auto_drop => FALSE);
    END;
    Check if your schedule EVENT_JOB_SCHED is enabled

  • JMS Text Msg Payload - Oracle 8i

    I am using Oracle8i Enterprise Edition Release 8.1.7.4.0 for creating a queue uisng Oracle AQ with payload type
    SYS.AQ$_JMS_TEXT_MESSAGE. When I tried create a queue, I found some of components in SYS.AQ$_JMS_TEXT_MESSAGE are missing in Oracle 8i. Without those components usage, the message cannot set as payload in the queue. The explanation is as below.
    My script for creation of queue is as follows..
    CREATE OR REPLACE PROCEDURE NCR_ESB_NOL_SCRIPT(order_clob_load in CLOB)
    IS
    qtable_present number;
    queue_present number;
    enqopt dbms_aq.enqueue_options_t;
    msgprop dbms_aq.message_properties_t;
    enq_msgid raw(10000);
    order_headers_clob clob;
    msgsize number(38);
    message sys.aq$_jms_text_message;
    clob_msg_queuetable varchar2(100);
    clob_msg_queue varchar2(100);
    BEGIN
    -- Queue table and queue
    clob_msg_queuetable := 'TEST_QTAB';
    clob_msg_queue := 'TEST_Q';
    order_headers_clob := order_clob_load;
    --create queue table
    select count(*) into qtable_present from user_tables where table_name = 'TEST_QTAB';
         if (qtable_present <> 1)
         then
              dbms_aqadm.create_queue_table(queue_table => clob_msg_queuetable,
                                            multiple_consumers => TRUE,
                                       queue_payload_type => 'SYS.AQ$_JMS_TEXT_MESSAGE',
                                       compatible => '8.1');
         end if;
    --create queue 
    select count(*) into queue_present from user_queues where name = 'TEST_Q';
         if (queue_present <> 1)
         then
              dbms_aqadm.create_queue(queue_name=>clob_msg_queue,
    queue_table => clob_msg_queuetable,
    retention_time => 86400);
    dbms_aqadm.add_subscriber(clob_msg_queue, SYS.AQ$_AGENT ('OA', NULL, NULL));
         end if;
    dbms_aqadm.start_queue(clob_msg_queue);
    message := sys.aq$_jms_text_message.construct;
    message.setText(order_headers_clob);
    dbms_aq.enqueue(
    queue_name => clob_msg_queue, -- IN
    enqueue_options => enqopt, -- IN
    message_properties => msgprop, -- IN
    payload => message, -- IN
    msgid => enq_msgid); -- OUT
    COMMIT;
    When I tried the above script, I got error as follows.
    PL/SQL: Statement ignored
    PLS-00302: component 'CONSTRUCT' must be declared
    PL/SQL: Statement ignored
    PLS-00302: component 'SETTEXT' must be declared
    When I tried DESC SYS.AQ$_JMS_TEXT_MESSAGE , it shows as :
    SQL> DESC SYS.AQ$_JMS_TEXT_MESSAGE
    Name Null? Type
    HEADER AQ$_JMS_HEADER
    TEXT_LEN NUMBER(38)
    TEXT_VC VARCHAR2(4000)
    TEXT_LOB CLOB
    It does not show the components CONSTRUCT and SET_TEXT. Also I will be in need of GET_TEXT component also to dequeue the queue data and test it. I would like to know whether the components CONSTRUCT and SET_TEXT are availble in Oracle 8i or not. Without those components, is there any other way to set payload in the queue?
    Help in this regard from any body who knows about this is really appreciated.
    Thanks

    Hi, not sure where you have sorted this out yet, but I ended up creating my own wrappers. Hope these are of use:
    FUNCTION new_properties
    RETURN SYS.AQ$_JMS_USERPROPARRAY
    IS
    l_prop_arr SYS.AQ$_JMS_USERPROPARRAY;
    BEGIN
    l_prop_arr := SYS.AQ$_JMS_USERPROPARRAY();
    RETURN l_prop_arr;
    END new_properties;
    FUNCTION new_agent
    RETURN SYS.AQ$_AGENT
    IS
    c_name CONSTANT VARCHAR2(30) := NULL;
    c_address CONSTANT VARCHAR2(100) := NULL;
    c_protocol CONSTANT NUMBER := 0;
    l_agent SYS.AQ$_AGENT;
    BEGIN
    l_agent := SYS.AQ$_AGENT(c_name, c_address, c_protocol);
    RETURN l_agent;
    END new_agent;
    FUNCTION new_header
    RETURN SYS.AQ$_JMS_HEADER
    IS
    c_type CONSTANT VARCHAR2(100) := NULL;
    c_jms_userid CONSTANT VARCHAR2(100) := 'waveq';
    c_appid CONSTANT VARCHAR2(100) := NULL;
    c_groupid CONSTANT VARCHAR2(100) := NULL;
    c_groupseq CONSTANT INTEGER := 1;
    l_replyto SYS.AQ$_AGENT;
    l_proparr SYS.AQ$_JMS_USERPROPARRAY;
    l_jms_header SYS.AQ$_JMS_HEADER;
    BEGIN
    l_replyto := new_agent();
    l_proparr := new_properties();
    l_jms_header := SYS.AQ$_JMS_HEADER(l_replyto, c_type, c_jms_userid, c_appid, c_groupid, c_groupseq, l_proparr);
    RETURN l_jms_header;
    END new_header;
    FUNCTION new_payload(
    io_message IN OUT NOCOPY VARCHAR2)
    RETURN SYS.AQ$_JMS_TEXT_MESSAGE
    IS
    c_text_len CONSTANT INTEGER := 0;
    c_text_vc CONSTANT VARCHAR2(4000) := NULL;
    c_text_lob CONSTANT CLOB := EMPTY_CLOB();
    l_header SYS.AQ$_JMS_HEADER;
    l_jms_message SYS.AQ$_JMS_TEXT_MESSAGE;
    BEGIN
    l_header := new_header();
    l_jms_message := SYS.AQ$_JMS_TEXT_MESSAGE(l_header, c_text_len, c_text_vc, c_text_lob);
    l_jms_message.text_vc := io_message;
    l_jms_message.text_len := LENGTH(io_message);
    RETURN l_jms_message;
    END new_payload;

  • PL/SQL Call Back function is never called

    Hi, I have a AQ set to run a PL/SQL Call Back procedure, but the procedure is never called.
    Oracle version is 11.2.0.2 Standard Edition
    When I query aq$<queue>, the MSG_STATE column is always "ready".
    This is the queue creation script
    begin
      DBMS_AQADM.CREATE_QUEUE_TABLE ( queue_table => 'POLERMESSAGE',
                                      queue_payload_type => 'POLER_MESSAGE',
                                      multiple_consumers => TRUE );
      DBMS_AQADM.CREATE_QUEUE( queue_name => 'POLER_QUEUE',
                               queue_table => 'POLERMESSAGE');
      dbms_aqadm.add_subscriber( queue_name => 'POLER_QUEUE',
                                 subscriber => sys.aq$_agent( 'POLER_RECIPIENT', null, null ) );    
      dbms_aq.register ( sys.aq$_reg_info_list( sys.aq$_reg_info('POLER_QUEUE:POLER_RECIPIENT',
                                                                 dbms_aq.namespace_aq,
                                                                 'plsql://tr',
                                                                 HEXTORAW('FF')) ) ,
                           1 );    
      DBMS_AQADM.START_QUEUE(queue_name => 'POLER_QUEUE');    
    end;
    /This is the content of "tr" procedure
    create or replace
    procedure tr ( context raw,
                           reginfo sys.aq$_reg_info,
                           descr sys.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 poler_message;
    BEGIN
      dequeue_options.msgid := descr.msg_id;
      dequeue_options.consumer_name := descr.consumer_name;
      DBMS_AQ.DEQUEUE(queue_name => descr.queue_name,
                      dequeue_options => dequeue_options,
                      message_properties => message_properties,
                      payload => message,
                      msgid => message_handle);
      insert into lxtr values ( Nvl( To_Char(message.PolerMsgNro ), 'ooops' ), systimestamp ) ;
      commit ;
    end tr;If I query sys.reg$, I see it registered there:
    SQL> select subscription_name, location_name, status, state from sys.reg$;
    SUBSCRIPTION_NAME
    LOCATION_NAME
       STATUS     STATE
    "SPARCS"."POLER_QUEUE":"POLER_RECIPIENT"
    plsql://tr
            0         0I was working, until I re-compiled (don't ask...) the trigger that enqueue the message
    This is the section of the trigger (post insert for each row) that do the enqueuing. It seems to be working, since it is enqueuing. The issue is the dequeue.
    DECLARE
      enqueue_options dbms_aq.enqueue_options_t;
      message_properties dbms_aq.message_properties_t;
      message_handle RAW(16);
      message poler_message;
      err varchar2(2000);
    BEGIN
        message := poler_message(PolerMsgId,  PolerMsgNro );
        dbms_aq.enqueue(queue_name => 'POLER_QUEUE',
                        enqueue_options => enqueue_options,
                        message_properties => message_properties,
                        payload => message,
                        msgid => message_handle);
    END;If I run the code below, message is cleanly dequeued
    declare
      dequeue_options      dbms_aq.dequeue_options_t;
      message_properties   dbms_aq.message_properties_t;
      message_handle       RAW(16);
      message              poler_message;
    BEGIN
      dequeue_options.consumer_name := 'POLER_RECIPIENT' ;
      dbms_aq.dequeue( queue_name => 'POLER_QUEUE',
                       dequeue_options       => dequeue_options,
                       message_properties    => message_properties,
                       payload               => message,
                       msgid                 => message_handle);
      COMMIT;
    END ;Can anyone please give me any hints on what should I do next. There is nothing on the alert log...
    Thank you in advance,
    Tiago

    1) Very few PL/SQL programmers would consider it good form to have procedures with excessive numbers of parameters. In any language, though, it's possible to write poor code.
    2) Initially, you're right-- the performance of properly defined SQL statements via JDBC is little different than the performance of PL/SQL stored procedures. Frequently, however, SQL statements in Java applications do not take advantage of bind variables, which will significantly limit their scalability. Maintaining SQL statements in client applications makes it significantly more difficult on the support side-- if you find a bug in a stored procedure, you can fix the bug in one place-- if you find a bug in embedded SQL, you have to fix the code everywhere the client is deployed. Maintaining PL/SQL stored procedures also makes optimization easier-- frequently your DBA will be able to boil down a stored procedure to a couple of SQL statements and vastly improve performance (i.e. INSERT INTO <<table name>> SELECT <<column list>> from <<other table>> rather than looping over a cursor doing single-row inserts). Finally, PL/SQL stored procedures enable reuse-- when the next application wants to access the database, it doesn't have to rewrite your SQL.
    3) If the alternative to the bind variables (?'s) is a bunch of literals, I'll spend the extra time writing the code for the tremendous increase in scalability.
    4-6) You can certainly pass classes from Java to PL/SQL and back. You can also write Java stored procedures, rather than writing PL/SQL stored procedures). Oracle has been one of the leading proponents of Java.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • The Publish-Subscribe Notification latency in OCI is 5 seconds

    I have an OCI application where I register a callback to receive publish-subscribe notifications from an Oracle queue.
    The problem that I have is that I am receiving messages every 5 seconds intervals (the callback is called every 5 seconds if there are messages in the queue).
    It looks like that there is a process that is monitoring the database queue every 5 seconds. Is there a way to change that behavior?.
    I am getting the same behavior in Windows and Linux systems.
    This is the PL/SQL code that I am executing to create the database queue:
    DECLARE
    subscriber sys.aq$_agent;
    BEGIN
    DBMS_AQADM.CREATE_QUEUE_TABLE(
    QUEUE_TABLE=>'TestUser."TestTable_msg_table"',
    MULTIPLE_CONSUMERS => TRUE,
    QUEUE_PAYLOAD_TYPE =>'RAW');
    DBMS_AQADM.CREATE_QUEUE(
    QUEUE_NAME=>'TestUser."TestTable_queue"',
    QUEUE_TABLE=>'TestUser."TestTable_msg_table"');
    DBMS_AQADM.START_QUEUE('TestUser."TestTable_queue"');
    subscriber := sys.aq$_agent('AGENT', null, null);
    DBMS_AQADM.ADD_SUBSCRIBER(
    QUEUE_NAME=> 'TestUser."TestTable_queue"',
    SUBSCRIBER => subscriber,
    DELIVERY_MODE => DBMS_AQ.BUFFERED);
    END;
    CREATE OR REPLACE TRIGGER TestUser."TestTable_changes"
    AFTER DELETE OR INSERT OR UPDATE ON TestUser."TestTable"
    FOR EACH ROW
    DECLARE
    enq_ct dbms_aq.enqueue_options_t;
    msg_prop dbms_aq.message_properties_t;
    enq_msgid raw(16);
    userdata raw(100);
    BEGIN
    enq_ct.visibility := DBMS_AQ.IMMEDIATE;
    enq_ct.delivery_mode := DBMS_AQ.BUFFERED;
    msg_prop.delay := DBMS_AQ.NO_DELAY;
    DBMS_AQ.ENQUEUE('TestUser."TestTable_queue"',enq_ct, msg_prop,userdata,enq_msgid);
    END;
    This is the OCI code that I am executing to register for changes into the queue:
    /* Allocate subscription */
    OCIHandleAlloc((dvoid *)hEnv,(dvoid **)&hSub,
              (ub4) OCI_HTYPE_SUBSCRIPTION,
              (size_t) 0, (dvoid **) 0);
    OCIAttrSet((dvoid *)hSub, (ub4) OCI_HTYPE_SUBSCRIPTION,
    (dvoid *) subName, (ub4) strlen(subName),
    (ub4) OCI_ATTR_SUBSCR_NAME, hError);
    /* Subscription callback */
    OCIAttrSet((dvoid *)hSub,(ub4)OCI_HTYPE_SUBSCRIPTION,
    (dvoid *) onTableChange, (ub4) 0,
    (ub4) OCI_ATTR_SUBSCR_CALLBACK, hError);
    /* Set subscription context */
    OCIAttrSet((dvoid *) tblInfo, (ub4) OCI_HTYPE_SUBSCRIPTION,
    (dvoid *) 0, (ub4) 0,
    (ub4) OCI_ATTR_SUBSCR_CTX, hError);
    /* Set subscription namespace */
    OCIAttrSet((dvoid *) hSub, (ub4) OCI_HTYPE_SUBSCRIPTION,
    (dvoid *) &subNamespace, (ub4) 0,
    (ub4) OCI_ATTR_SUBSCR_NAMESPACE, hError);
    /* Begining Registration for subscription */
    OCISubscriptionRegister(hSvc,&hSub,1,hError,OCI_DEFAULT);
    Thanks

    This has come up before. No definitive solution but a purge of the queue is worth a try:
    see=> Re: Dequeing happens only every 5 Seconds

  • Notification with user defined type results in PLS-00306: wrong number..

    I created a user defined type TLogMessage:
    CREATE OR REPLACE TYPE TLogMessage AS OBJECT
    module VARCHAR2(4000),
    severity NUMBER,
    message VARCHAR2(4000)
    I also created a multi-consumer queue using this type as payload.
    My callback procedure in the package PK_SYST_LOGMESSAGE is defined as follows:
         PROCEDURE DefaultLoggerCallback(
              context          RAW,
              reginfo          SYS.AQ$_REG_INFO,
              descr          SYS.AQ$_DESCRIPTOR,
              payload          RAW,
              payload1     NUMBER
    Finally, I registered the callback procedure as follows:
              DBMS_AQADM.ADD_SUBSCRIBER(
                   queue_name      => QUEUE_NAME,
                   subscriber      => SYS.AQ$_AGENT(
                                            name => 'default_logger',
                                            address => NULL,
                                            protocol => NULL
              DBMS_AQ.REGISTER(
                   SYS.AQ$_REG_INFO_LIST(
                        SYS.AQ$_REG_INFO(
                             name          => QUEUE_NAME || ':default_logger',
                             namespace     => DBMS_AQ.NAMESPACE_AQ,
                             callback     => 'plsql://MTDX.PK_SYST_LOGMESSAGE.DefaultLoggerCallback',
                             context          => HEXTORAW('FF')
                   1
    However, when I put a message in the queue using this procedure:
         PROCEDURE LogMessage(
              pModule          VARCHAR2,
              pSeverity     NUMBER,
              pMessage     VARCHAR2
         IS
              vMessage               TLogMessage;
              vEnqueueOptions          DBMS_AQ.ENQUEUE_OPTIONS_T;
              vMsgProperties          DBMS_AQ.MESSAGE_PROPERTIES_T;
              vMessageHandle          RAW(16);
         BEGIN
              vMessage := TLogMessage(module => pModule, severity => pSeverity, message => pMessage);
              vEnqueueOptions.visibility := DBMS_AQ.IMMEDIATE;
              vMsgProperties.correlation := pModule;
              vMsgProperties.priority := -pSeverity;
              -- Enqueue the message to all subscribers
              DBMS_AQ.ENQUEUE(
                   queue_name               => QUEUE_NAME,
                   enqueue_options          => vEnqueueOptions,
                   message_properties     => vMsgProperties,
                   payload                    => vMessage,
                   msgid                    => vMessageHandle
         EXCEPTION
              WHEN no_subscribers THEN
                   -- No subscribers on the queue; ignore
                   NULL;
         END;
    I can see the message in the queue, by querying the queue view. I can also see that Oracle tried to call my callback procedure, because in the trace file I see the following:
    *** 2009-02-13 08:52:25.000
    *** ACTION NAME:() 2009-02-13 08:52:24.984
    *** MODULE NAME:() 2009-02-13 08:52:24.984
    *** SERVICE NAME:(SYS$USERS) 2009-02-13 08:52:24.984
    *** SESSION ID:(609.3387) 2009-02-13 08:52:24.984
    Error in PLSQL notification of msgid:4F7962FEDD3B41FA8D9538F0B38FCDD1
    Queue :"MTDX"."LOGMESSAGE_QUEUE"
    Consumer Name :DEFAULT_LOGGER
    PLSQL function :MTDX.PK_SYST_LOGMESSAGE.DefaultLoggerCallback
    : Exception Occured, Error msg:
    ORA-00604: Fout opgetreden bij recursief SQL-niveau 2.
    ORA-06550: Regel 1, kolom 7:
    PLS-00306: Onjuist aantal of type argumenten in aanroep naar 'DEFAULTLOGGERCALLBACK'..
    ORA-06550: Regel 1, kolom 7:
    PL/SQL: Statement ignored.
    So.. how many parameters does Oracle expect, and of what type? Is there any way to find out? What is wrong with my code?

    Ok, found it... I had defined the last parameter of the callback procedure as 'payload1' (that is: 'payload-ONE') instead of 'payloadl' ('payload-ELL'). It all works like a charm now.
    What a way to waste two whole days!

  • Messages in Ready state are not dequeuing.

    Messages are being left in a "Ready" state. Everything was working fine in 10g. However there was an upgrade to 11g and now queues have stop working. It is a multiconsumer queue with one subscriber. I can manually dequeue messages but the subscriber call back does not seem to function.
    -- Create and start queues and queue_table
    BEGIN
         DBMS_AQADM.CREATE_QUEUE_TABLE (
              queue_table => 'muse.m_en_queue_table',
              queue_payload_type => 'muse.eu_logid_type',
              multiple_consumers => TRUE
         DBMS_AQADM.CREATE_QUEUE (
              queue_name => 'xxxxx.m_en_queue',
              queue_table => 'xxxxx.m_en_queue_table'
         DBMS_AQADM.START_QUEUE('xxxxx.m_en_queue');
         --Start Default Exception Queue
         DBMS_AQADM.START_QUEUE('xxxxx.AQ$_M_EN_QUEUE_TABLE_E', enqueue => FALSE, dequeue => TRUE);
         DBMS_AQADM.ALTER_QUEUE (
              queue_name => 'xxxxx.m_en_queue',
              max_retries => 2,
    retry_delay => 10);
    END;
    --Procedure to dequeue messages and try to resend to the notification service
    CREATE OR REPLACE PROCEDURE muse.m_en_queue_callback_procedure(
         context RAW,
    reginfo SYS.AQ$_REG_INFO,
    descr SYS.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);
         o_payload      muse.eu_logid_type;
         change_rec           muse.eocd_update%rowtype;
    BEGIN
    dequeue_options.WAIT := DBMS_AQ.no_wait;
    dequeue_options.msgid := descr.msg_id;
    dequeue_options.consumer_name := descr.consumer_name;
    DBMS_AQ.DEQUEUE(
    queue_name => descr.queue_name,
    dequeue_options => dequeue_options,
    message_properties => message_properties,
    payload => o_payload,
    msgid => message_handle
    END;
    --Subscribed to queue
    BEGIN
    DBMS_AQADM.ADD_SUBSCRIBER (
    queue_name => 'xxxxx.m_en_queue',
    subscriber => SYS.AQ$_AGENT(
    'muse_en_queue_subscriber',
    NULL,
    NULL )
    DBMS_AQ.REGISTER (
    SYS.AQ$_REG_INFO_LIST(
    SYS.AQ$_REG_INFO(
    'xxxxx.M_EN_QUEUE:MUSE_EN_QUEUE_SUBSCRIBER',
    DBMS_AQ.NAMESPACE_AQ,
    'plsql://xxxxx.m_en_queue_callback_procedure',
    HEXTORAW('FF')
    1
    END;
    /

    Hi,
    What version specifically of 11g did you upgrade to?
    Did you review the following MOS notes?
    Event Monitor Process: Architecture and Known Issues (Doc ID 105067.1)
    AQ PL/SQL Notification No Longer Work Due To "register_driver()" Jobs Not Terminating (Doc ID 331372.1)
    Thanks
    Paul

  • 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.

  • Oracle AQ: Message not removed from source queue after propagation

    Hi.
    I have been playing around with a test setup for a "fanning out"-propagation system.
    I have created three queues, SRC_Q, DEST_Q and DEST2_Q.
    The propagation seems to work fine, the messages that I put on the SRC_Q get propagated to the destination queues. However, after propagation the message does not get removed from the source queue. Could anyone tell me why?
    I am using Oracle 10g.
    Here is my setup:
    --Test payload
    CREATE OR REPLACE TYPE test_payload AS OBJECT(
    test_id NUMBER,
    test_dt DATE);
    commit;
    DECLARE
    subscriber SYS.aq$_agent;
    BEGIN
    --- Create Originating Queue and start it
    DBMS_AQADM.create_queue_table( queue_table => 'SRC_MQT', queue_payload_type => 'Test_Payload',
    multiple_consumers => TRUE );
    DBMS_AQADM.create_queue( 'SRC_Q', 'SRC_MQT' );
    DBMS_AQADM.start_queue( queue_name => 'SRC_Q' );
    --- Create Destination Queue and start it
    DBMS_AQADM.create_queue_table( queue_table => 'Dest_MQT', queue_payload_type => 'Test_Payload',
    multiple_consumers => TRUE );
    DBMS_AQADM.create_queue( 'Dest_Q', 'Dest_MQT' );
    DBMS_AQADM.start_queue( queue_name => 'Dest_Q' );
    --- Create Destination Queue2 and start it
    DBMS_AQADM.create_queue_table( queue_table => 'Dest2_MQT', queue_payload_type => 'Test_Payload',
    multiple_consumers => TRUE );
    DBMS_AQADM.create_queue( 'Dest2_Q', 'Dest2_MQT' );
    DBMS_AQADM.start_queue( queue_name => 'Dest2_Q' );
    --- Add Subscribers and schedule propagation
    subscriber := SYS.aq$_agent( 'test_sub', 'Dest_Q', NULL );
    DBMS_AQADM.add_subscriber( queue_name => 'SRC_Q', subscriber => subscriber , queue_to_queue=> TRUE);
    subscriber := SYS.aq$_agent( 'test_sub2', 'Dest2_Q', NULL );
    DBMS_AQADM.add_subscriber( queue_name => 'SRC_Q', subscriber => subscriber , queue_to_queue=> TRUE );
    --Propagation to queues
    DBMS_AQADM.schedule_propagation( queue_name => 'SRC_Q', destination_queue => 'Dest_Q' );
    DBMS_AQADM.schedule_propagation( queue_name => 'SRC_Q', destination_queue => 'Dest2_Q' );
    commit;
    END;
    --Put something on the queue
    DECLARE
    message_handle RAW( 16 );
    MESSAGE test_payload;
    nq_opt dbms_aq.enqueue_options_t;
    nq_pro dbms_aq.message_properties_t;
    begin
    nq_opt.visibility := dbms_aq.immediate;
    nq_pro.expiration := dbms_aq.never;
    MESSAGE := test_payload( 2, SYSDATE );
    DBMS_AQ.enqueue( 'SRC_Q', nq_opt,nq_pro,MESSAGE, message_handle );
    COMMIT;
    END;
    I am really stuck with this problem so I really hope somebody have some advice on what I am doing wrong.

    I am also facing a similar issue. I have a multiconsumer queue. The message has been dequeued but the message is still present in the queue table and the message is also present in AQ$<queue_name> and the state is being shown as 'processed'.
    This all was working fine few days back and somehow stopped working all of sudden. The DB version which I am using is - 11.1.0.7.0. Any help related to this will be greatly appreciated
    -AA

  • Message not moving to default exception queue when max retries reached

    Hi
    I've set up an advanced queue with max retrie of 5 but when the dequing fails the retry count increments but it never goes to the exception queue. The retry count stays at 6, msg_state = READY, deq_txn_id = RETRY_EXCEEDED. Any ideas?
    -- drop queue if it exists
    exec dbms_aqadm.stop_queue (queue_name => 'AQ$_JY_METER_ENABLE_QTAB_E');
    exec dbms_aqadm.stop_queue (queue_name => 'JY_METER_ENABLE_QUE');
    exec dbms_aqadm.drop_queue (queue_name  => 'JY_METER_ENABLE_QUE') ;
    exec dbms_aqadm.drop_queue_table( queue_table => 'JY_METER_ENABLE_QTAB');
    -- create the payload for the messages
    CREATE TYPE jy_meter_enablement_typ AS OBJECT
    request_id                VARCHAR2(30) ,
    request_system_code       VARCHAR2(20) ,
    business_process_ref      VARCHAR2(20) ,
    request_type_ref          VARCHAR2(20) ,
    meter_serial_number       VARCHAR2(10) ,
    message_request_content   CLOB
    -- Create queue table.
    -- This one has a sort list so items will be enqueued first based on priority and then based on enq_time
    BEGIN
       dbms_aqadm.create_queue_table (queue_table        => 'JY_METER_ENABLE_QTAB',
                                      queue_payload_type => 'JY_METER_ENABLEMENT_TYP',
                                      multiple_consumers => TRUE ,
                                      sort_list          => 'priority,enq_time' ,
                                      comment            => 'Queue table to handle JY Meter Enablement messages');
    END;
    -- Create Queue based on table
    BEGIN
      -- retention time set 3600 seconds (ie 1 hour) so the message is kept on the queue for 1 hour after it has been dequeued.
       dbms_aqadm.create_queue (queue_name     => 'JY_METER_ENABLE_QUE',
                                queue_table    => 'JY_METER_ENABLE_QTAB' ,
                                max_retries    => 5 ,
                                retry_delay    => 2 ,
                                retention_time => 3600 ,
                                comment     => 'Queue to handle JY Meter Enablement messages in priority/enq_time order');
    END;
    -- start the queue
    BEGIN
    dbms_aqadm.start_queue (queue_name => 'JY_METER_ENABLE_QUE');
    END ;
    -- Add and register a subscriber to the queue to run the Dequeue procedure
    BEGIN
       dbms_aqadm.add_subscriber (queue_name => 'EMO_METER_MGMT.JY_METER_ENABLE_QUE',
                                  subscriber => SYS.AQ$_AGENT('JY_METER_ENABLE_QUE_SUBSCRIBER',
                                                              NULL,
                                                              NULL )
        dbms_aq.register (SYS.AQ$_REG_INFO_LIST(SYS.AQ$_REG_INFO('JY_METER_ENABLE_QUE:JY_METER_ENABLE_QUE_SUBSCRIBER',
                                                                 DBMS_AQ.NAMESPACE_AQ,
                                                                 'plsql://EMO_METER_MGMT.DEQUEUE.dequeue_jy_request',
                                                                 HEXTORAW('FF'))),1);
    END;
    -- start the default exception queue
    BEGIN
    dbms_aqadm.start_queue(queue_name => 'EMO_METER_MGMT.AQ$_JY_METER_ENABLE_QTAB_E',
                            enqueue => FALSE,
                            dequeue => TRUE);
    END ;
    /Thanks

    Sorry, forgot to add db version
    select banner from v$version/
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE 11.2.0.2.0 Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    5 rows selected.

  • 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.

  • Enqueue works fine Dequeue works when run manually but not via Notification

    Hi,
    My Enqueue works fine. My Dequeue procedure works fine when run manually. But when I register a notification the procedure is not called.
    The log file shows:
    ORACLE_HOME = /u01/app/oracle/product/10.2.0
    System name: Linux
    Node name: gooch.com
    Release: 2.4.21-50.ELsmp
    Version: #1 SMP Tue May 8 17:18:29 EDT 2007
    Machine: i686
    Instance name: xml
    Redo thread mounted by this instance: 1
    Oracle process number: 25
    Unix process pid: 7761, image: [email protected] (J000)
    *** 2010-03-06 14:09:22.167
    *** ACTION NAME:() 2010-03-06 14:09:22.167
    *** MODULE NAME:() 2010-03-06 14:09:22.167
    *** SERVICE NAME:(SYS$USERS) 2010-03-06 14:09:22.167
    *** SESSION ID:(145.99) 2010-03-06 14:09:22.167
    Error in PLSQL notification of msgid:8128C090A10BE480E0407E0A660F1B97
    Queue :"XML4"."TEST14_Q"
    Consumer Name :TEST14
    PLSQL function :xml4.test14_proc
    : Exception Occured, Error msg:
    ORA-00604: error occurred at recursive SQL level 2
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'TEST14_PROC'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    my code is
    BEGIN
      DBMS_AQADM.CREATE_QUEUE_TABLE(
         queue_table        => 'test14_t',
         comment            => 'Queue Table to process incoming ORDER XML messages from Management Dynamics',
         multiple_consumers => TRUE,
         queue_payload_type => 'SYS.XMLTYPE',
         compatible         => '8.1');
    END;
    BEGIN
      DBMS_AQADM.CREATE_QUEUE(
        queue_name  => 'test14_q',
        queue_table => 'test14_t');
    END;
    BEGIN
    dbms_aqadm.start_queue('test14_q');
    END;
    BEGIN
      DBMS_AQADM.ADD_SUBSCRIBER (
         queue_name => 'test14_q',
         subscriber => SYS.AQ$_AGENT('test14', NULL, NULL)
    END;
    CREATE or replace PROCEDURE test14_proc AS
      deq_opts dbms_aq.dequeue_options_t;
      mess_prop dbms_aq.message_properties_t;
      mess_handle RAW(16);
      message XMLTYPE;
      buffer varchar2(100);
      msglen number;
    begin
      deq_opts.wait := dbms_aq.FOREVER;
      deq_opts.consumer_name := 'test14';
      dbms_aq.dequeue(queue_name=> 'test14_q',
                      dequeue_options => deq_opts,
                      message_properties => mess_prop,
                      payload => message,
                      msgid => mess_handle);
      commit;
      insert into testxml values(message);
      commit;
      insert into hello select extractvalue(xml1, '/Hello') from testxml;
      commit;
    end test14_proc;
    DECLARE
      queue_options DBMS_AQ.ENQUEUE_OPTIONS_T;
      message_properties DBMS_AQ.MESSAGE_PROPERTIES_T;
      message_id RAW(16);
      message SYS.XMLType;
    BEGIN
      message := sys.XMLType.createXML('<?xml version="1.0"?><Hello>Test</Hello>');
      DBMS_AQ.ENQUEUE( queue_name => 'test14_q',
                       enqueue_options => queue_options,
                       message_properties => message_properties,
                       payload => message,
                       msgid => message_id);
      COMMIT;
    END;
    BEGIN
      DBMS_AQ.REGISTER (
          SYS.AQ$_REG_INFO_LIST(
            SYS.AQ$_REG_INFO(
              'xml4.test14_q:test14',
               DBMS_AQ.NAMESPACE_AQ,
               'plsql://xml4.test14_proc?PR=0',
               HEXTORAW('FF'))),1);
      END;Any ideas?
    Thanks in advance!

    I actually changed it to process RAW as well i.e.
    BEGIN
      DBMS_AQ.REGISTER (
          SYS.AQ$_REG_INFO_LIST(
            SYS.AQ$_REG_INFO(
              'xml4.test14_q:test14',
               DBMS_AQ.NAMESPACE_AQ,
               'plsql://xml4.test14_proc?PR=0',
               HEXTORAW('FF'))),1);
      END;and it still is failing with the same error

  • Problems with dbms_aq.listen

    I am having problem trying to listen to a set of queues.
    I have tried it with Single Consumer queues and it works fine.
    But with Multi Consumer queues dbms_aq.listen does not detect a new message enqueued and just waits until the time out then returns with the normal "No message" exception.
    Can any one tell me what I am doing wrong?
    Thanks
    Rick Laird
    code
    CREATE OR REPLACE TYPE message_type AS OBJECT (xml_message CLOB);
    exec dbms_aqadm.create_queue_table('testqueue_qtable','message_type',Null,Null,true);
    exec dbms_aqadm.create_queue('testqueue', 'testqueue_qtable');
    exec dbms_aqadm.start_queue('testqueue');
    exec dbms_aqadm.add_subscriber('testqueue',sys.aq$_agent('testqueue_subscriber',NULL,NULL));
    exec DBMS_AQADM.SCHEDULE_PROPAGATION('testqueue');
    CREATE OR REPLACE PROCEDURE MONITOR_STATUS_QUEUE(time IN NUMBER)
    IS
    pragma autonomous_transaction;
    agent_w_message sys.aq$_agent;
    agent_list dbms_aq.aq$_agent_list_t;
    wait_time INTEGER := 10;
    no_message EXCEPTION;
    pragma EXCEPTION_INIT(no_message, -25254);
    new_status VARCHAR2(30);
    monitor BOOLEAN := TRUE;
    begin_time number;
    end_time number;
    v_dequeue_options dbms_aq.dequeue_options_t;
    v_message_properties dbms_aq.message_properties_t;
    v_message_type message_type;
    v_dequeue_msg_id RAW(40);
    v_xml_message CLOB;
    v_message_text varchar2(2000);
    v_amount number;
    BEGIN
    begin_time := dbms_utility.get_time;
    WHILE (monitor)
    LOOP
    BEGIN
    -- agent_list(1) := sys.aq$_agent('testqueue_agent', 'testqueue', NULL);
    agent_list(1) := sys.aq$_agent('agent1', 'testqueue', NULL);
    /* wait for order status messages */
    dbms_aq.listen(agent_list, 0, agent_w_message);
    dbms_output.put_line('Agent' || agent_w_message.name || ' Address '|| agent_w_message.address);
    /* dequeue the message from the queue */
    v_dequeue_options.consumer_name := 'testqueue_subscriber';
    v_dequeue_options.wait := 0.5;
    -- v_dequeue_options.wait := dbms_aq.NO_WAIT;
    dbms_aq.dequeue('testqueue',v_dequeue_options, v_message_properties,
    v_message_type,v_dequeue_msg_id);
    v_amount := dbms_lob.getlength(v_message_type.xml_message);
    dbms_lob.read(v_message_type.xml_message,v_amount,1,v_message_text);
    dbms_output.put_line('New Message :'||v_message_text);
    /* exit if we have been working long enough */
    end_time := dbms_utility.get_time;
    IF (end_time - begin_time > time) THEN
    EXIT;
    END IF;
    EXCEPTION
    WHEN no_message THEN
    dbms_output.put_line('No messages so far');
    end_time := dbms_utility.get_time;
    --exit if we have done enough work
    IF (end_time - begin_time > time) THEN
    EXIT;
    END IF;
    END;
    END LOOP;
    commit;
    END;
    create or replace procedure enqueue is
    v_enqueue_options dbms_aq.enqueue_options_t;
    v_messages_properties dbms_aq.message_properties_t;
    v_message_type message_type;
    v_message_locator CLOB;
    v_enqueue_msg_id RAW(40);
    v_select_sql varchar2(2000);
    v_xml_message varchar2(2000);
    v_temp_clob CLOB;
    begin
    v_xml_message := '<TESTING><TEST>'||to_char(sysdate,'HH:MI:SS')||'</TEST></TESTING>';
    dbms_lob.createtemporary(v_temp_clob,true);
    dbms_lob.write(v_temp_clob,length(v_xml_message),1,v_xml_message);
    v_message_type := message_type(empty_clob());
    dbms_aq.enqueue(
    queue_name => 'testqueue',
    enqueue_options => v_enqueue_options,
    message_properties => v_messages_properties,
    payload => v_message_type,
    msgid => v_enqueue_msg_id);
    v_select_sql := ' select t.user_data.xml_message from testqueue_qtable t where t.msgid = :MSG_ID';
    execute immediate v_select_sql INTO v_message_locator using v_enqueue_msg_id;
    dbms_lob.copy( dest_lob => v_message_locator,
    src_lob => v_temp_clob,
    amount => dbms_lob.getlength(v_temp_clob));
    COMMIT;
    end enqueue;

    Hi,
    Your subscriber is called testqueue_subscriber. You must use the same consumer name in the agent list for dbms_aq.listen
    Change
    agent_list(1) := sys.aq$_agent('agent1', 'testqueue', NULL);
    to
    agent_list(1) := sys.aq$_agent('testqueue_subscriber', 'testqueue', NULL);

  • PL/SQL Callback notification with aq$_jms_text_message

    Hi,
    i want to set up a notfication for a pl/sql callback procedure. The message in my queue is enqueued via propagation from another instance. This is my setup (using oracle 10.2.0.3):
    -------- the queue (multiconsumer): --------------
    begin
    dbms_aqadm.create_queue_table(queue_table => 'zmon_evt_in_qtable',queue_payload_type => 'sys.aq$_jms_text_message', multiple_consumers => true);
    dbms_aqadm.create_queue(queue_name => 'zmon_evt_in_queue',queue_table => 'zmon_evt_in_qtable' );
    dbms_aqadm.start_queue( queue_name =>'zmon_evt_in_queue' );
    end;
    -------- the callback-procedure (simply inserting an entry in a table called 'test'): --------------
    create or replace procedure evt_in_callback(
    context IN RAW,
    reginfo IN SYS.AQ$_REG_INFO,
    descr IN SYS.AQ$_DESCRIPTOR,
    payload IN VARCHAR2,
    payloadl IN NUMBER) is
    begin
    insert into test(textfeld) values ('RECEIVED!');
    commit;
    end evt_in_callback;
    -------- the subscriber: --------------
    begin
    dbms_aqadm.add_subscriber(queue_name => 'zmon.zmon_evt_in_queue',
    subscriber => sys.aq$_agent('zmon_evt_in_subscriber',null,null));
    end;
    -------- the notification: --------------
    declare
    reginfo sys.aq$_reg_info;
    reg_list sys.aq$_reg_info_list;
    begin
    reginfo := sys.aq$_reg_info(name => 'zmon.zmon_evt_in_queue:zmon_evt_in_subscriber',
    namespace => DBMS_AQ.NAMESPACE_AQ,
    callback => 'plsql://zmon.evt_in_callback',
    context => HEXTORAW('FF')
    reg_list := sys.aq$_reg_info_list(reginfo);
    DBMS_AQ.REGISTER(reg_list => reg_list,
    reg_count => 1);
    end;
    The callback-procedure is not fired on arrival of a message in the queue. But i can see the the appropriate notfication-entry in sys.reg$.
    Any suggestions why this doesn't work ?
    BTW: can anybody tell me the meaning of the context-Parameter in the aq$_reg_info-Type ? Everybody uses HEXTORAW('FF'), but I don't understand what that means...
    Jens
    Edited by: dschenzl on Jun 4, 2009 11:13 AM

    Finally, it's done.
    The subscriber used in the propagation has to be the notification-subscriber (zmon_evt_in_subscriber). I used another subscriber, which was not registered for notification.
    I found the solution in this thread: Callback trouble from mesage via propagated message.
    Two days filled up with frustrating work - man, how i hate that...
    Greetings to the community,
    Jens

Maybe you are looking for