我正在使用Oracle 11g Advanced Queue。
我想为收件人创建一个多消费者队列,该队列将在邮件排队后稍后进行注册。收件人还应该接收队列中已经存在的邮件。
BEGIN
DBMS_AQADM.CREATE_QUEUE_TABLE(
queue_table => 'QUEUETABLE',
queue_payload_type => 'RAW',
multiple_consumers => TRUE,
comment => 'THIS IS A QUEUE TABLE' );
END;
BEGIN
DBMS_AQADM.CREATE_QUEUE (
queue_name => 'QUEUE',
queue_table => 'QUEUETABLE');
END;
BEGIN
DBMS_AQADM.START_QUEUE (
queue_name => 'QUEUE');
END;
BEGIN
dbms_aqadm.add_subscriber(
queue_name => 'QUEUE',
subscriber => sys.aq$_agent('QUEUE_SUBSCRIBER', null, null));
END;
CREATE OR REPLACE PROCEDURE ENQUEUE_PROC( p_item in RAW )
IS
enqueue_options dbms_aq.enqueue_options_t;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
recipients DBMS_AQ.aq$_recipient_list_t;
BEGIN
recipients(1) := sys.aq$_agent('QUEUE_SUBSCRIBER', NULL, NULL);
message_properties.recipient_list := recipients;
dbms_aq.enqueue(queue_name => 'QUEUE',
enqueue_options => enqueue_options,
message_properties => message_properties,
payload => p_item,
msgid => message_handle);
END;
现在,我必须注册一个接收已入队消息的使用者。 队列应该填满,并且在一定数量的消息之后,我想激活使用者。
有人知道怎么做吗?