暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 高级排队

ASKTOM 2021-01-13
543

问题描述

环境: 适用于视窗的Oracle 18XE 64位。
我有一个关于从持久队列出队消息数组的问题。
这是一个简单的点对点消息传递。队列是 “single_consumer”,没有传播。
我注册了我的PL/SQL回调函数。
我需要知道要出队的消息数组的确切大小
在我从Oracle AQ内部作业的回调函数的每次调用中。
我找到了唯一合法的方法。而这种方式就是注册callback
qosflags的参数sys。aq$reg_info等于dbms_aq。NTFN_QOS_PAYLOAD
这是注册PL/SQL块:
declare 
    v_qosflags number :=  dbms_aq。NTFN_QOS_PAYLOAD;
    r_info SYS。AQ$_REG_INFO;
   begin
      r_info := SYS。AQ$_REG_INFO(
                'STERN。FOUNDERS_QUEUE',
                DBMS_AQ。NAMESPACE_AQ,
                'plsql://stern。dosomecalc',
                HEXTORAW('FF')
                );
       r_info。qosflags := v_qosflags; 
       r_info。ntfn_grouping_class := dbms_aq。NTFN_GROUPING_CLASS_TIME ;  
       r_info。ntfn_grouping_value := 60;
       r_info。ntfn_grouping_type := dbms_aq。NTFN_GROUPING_TYPE_SUMMARY ;    
       
       DBMS_AQ。REGISTER (
          SYS。AQ$_REG_INFO_LIST(
                     r_info
             ),
          1
          );
 end;
复制

Here is the declaration of callback procedure。 It is a standard declaration:
create or replace procedure dosomecalc
(context    RAW
                             ,reginfo    SYS。AQ$_REG_INFO
                             ,descr      SYS。AQ$_DESCRIPTOR
                             ,payload    raw
                             ,payloadl   NUMBER)
复制


现在,谢天谢地qosflags parameter initialized 与dbms_aq。NTFN_QOS_PAYLOAD,我的回调函数的注册方式总是可以看到实际大小
of messages to dequeue in callback session。 It may be evaluated as counting size of descr。msgid_array part of descr parameter。
没有设置qosflags during registration to some value - this part of descr parameter always comes empty to callback procedure call。
一旦我知道消息数组的实际大小,我就可以在
Dbms_aq。dequeue_array(…, array_size => descr。msgid_array。count,…) /*dequeuing call*/。
复制

inside my callback function。
比,在分析了descr参数的内容后,我在其中发现了一个ntfnsRecdInGrp元素,
并决定ntfnsRecdInGrp 总是等于descr。msgid_array。count,
只是为了方便程序员,只是为了复制 descr。msgid_array。count
AQ文档说:
msgid_array  - Group notification message ID list
ntfnsRecdInGrp - Notifications received in group
复制

That was why I decided that they are equal by value。
It was a my mistake。 When I use callback 与array size equal to descr。msgid_array。count-
everything is OK。 With ntfnsRecdInGrp-no。 Sometimes descr。msgid_array。count
ntfnsRecdInGrp等于each other, sometimes not。
现在的问题是:
什么意思ntfnsRecdInGrpdescr参数的一部分?为什么它与
Msgid_array。count

专家解答

and decided that ntfnsRecdInGrp is always equal to descr.msgid_array.count,


通知与消息没有直接关系。在大多数常见用法中,您会收到有关消息的通知,因此它们似乎是一对一的。

从文档中

1.5.3 Notification Grouping by Time
Notification applications may register to receive a single notification for all events that occur within a specified time interval. Notification Clients may specify a start time for the notifications. Additionally, they must specify a time as the grouping class and the time interval as the grouping value.

A repeat count may be used to limit the number of notifications delivered. Clients can receive two types of grouping events, Summary or Last. A summary notification is a list of Message Identifiers of all the messages for the subscription. If last was specified as a grouping type, notification would have information about the last message in the notification interval. A count of the number of messages in the interval is also sent. The registration interfaces in PLSQL and OCI allow for specification of the START_TIME, REPEAT_COUNT, GROUPING CLASS, GROUPING VALUE, GROUPING TYPE in the AQ$_REGISTRATION_INFO and the OCI subscription Handle.


所以如果你想知道数组中有多少消息,那么使用数组计数。
文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论