Oracle高级队列(Advanced Queue)简单实例
Oracle高级队列(AdvancedQueue)简单实例
最简单的高级队列的练习,基本上都使用了默认参数。
--CreateType createorreplacetypenoteasObject( subjectvarchar2(100), Contentvarchar2(2000),CreateTimedate ); --Createqueuetable begin sys.dbms_aqadm.create_queue_table( queue_table=>'NOTETAB', queue_payload_type=>'TEST.NOTE' end; --createqueue begin sys.dbms_aqadm.create_queue( queue_name=>'NOTEQ', queue_table=>'NOTETAB', queue_type=>sys.dbms_aqadm.normal_queue, max_retries=>5, retry_delay=>0, retention_time=>0); end; --enqueue declare v_Messagenote; v_MsgIdRAW(16); v_optionsDBMS_AQ.ENQUEUE_OPTIONS_T; v_propertiesDBMS_AQ.MESSAGE_PROPERTIES_T; v_RecipientsDBMS_AQ.AQ$_RECIPIENT_LIST_T; begin v_Message:=note(subject=>'note3',Content=>'content3',createTime=>sysdate); --v_Recipients(0):=sys.aq$_agent('NOTE','MTQ',0); --v_properties.recipient_list:=v_Recipients; v_options.visibility:=DBMS_AQ.IMMEDIATE; dbms_aq.enqueue(queue_name=>'noteq',enqueue_options=>v_options,message_properties=>v_properties,payload=>v_Message,msgid=>v_MsgId); dbms_output.put_line('encodesuccess,msgidis'||v_MsgId); end; --dequeue declare v_Messagenote; v_MsgIdRAW(16); v_optionsDBMS_AQ.DEQUEUE_OPTIONS_T; v_propertiesDBMS_AQ.MESSAGE_PROPERTIES_T; v_RecipientsDBMS_AQ.AQ$_RECIPIENT_LIST_T; begin --v_Recipients(0):=sys.aq$_agent('NOTE','MTQ',0); --v_properties.recipient_list:=v_Recipients; v_options.visibility:=DBMS_AQ.IMMEDIATE; dbms_aq.dequeue(queue_name=>'noteq',dequeue_options=>v_options,message_properties=>v_properties,payload=>v_Message,msgid=>v_MsgId); dbms_output.put_line('decodesuccess,msgidis'||v_MsgId); dbms_output.put_line('subjectis'||v_Message.subject); dbms_output.put_line('Contentis'||v_Message.Content); dbms_output.put_line('createTimeis'||to_char(v_Message.createTime,'yyyy-mm-ddhh24:mi:ss')); end;
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!