问题描述
环境: 适用于视窗的Oracle 18XE 64位。
我有一个关于从持久队列出队消息数组的问题。
这是一个简单的点对点消息传递。队列是 “single_consumer”,没有传播。
我注册了我的PL/SQL回调函数。
我需要知道要出队的消息数组的确切大小
在我从Oracle AQ内部作业的回调函数的每次调用中。
我找到了唯一合法的方法。而这种方式就是注册callback
与qosflags的参数sys。aq$reg_info等于dbms_aq。NTFN_QOS_PAYLOAD。
这是注册PL/SQL块:
Here is the declaration of callback procedure。 It is a standard declaration:
现在,谢天谢地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。
一旦我知道消息数组的实际大小,我就可以在
inside my callback function。
比,在分析了descr参数的内容后,我在其中发现了一个ntfnsRecdInGrp元素,
并决定ntfnsRecdInGrp 总是等于descr。msgid_array。count,
只是为了方便程序员,只是为了复制 descr。msgid_array。count。
AQ文档说:
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?
我有一个关于从持久队列出队消息数组的问题。
这是一个简单的点对点消息传递。队列是 “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.
所以如果你想知道数组中有多少消息,那么使用数组计数。
通知与消息没有直接关系。在大多数常见用法中,您会收到有关消息的通知,因此它们似乎是一对一的。
从文档中
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进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
Oracle RAC 一键安装翻车?手把手教你如何排错!
Lucifer三思而后行
563次阅读
2025-04-15 17:24:06
【纯干货】Oracle 19C RU 19.27 发布,如何快速升级和安装?
Lucifer三思而后行
485次阅读
2025-04-18 14:18:38
Oracle SQL 执行计划分析与优化指南
Digital Observer
459次阅读
2025-04-01 11:08:44
XTTS跨版本迁移升级方案(11g to 19c RAC for Linux)
zwtian
454次阅读
2025-04-08 09:12:48
墨天轮个人数说知识点合集
JiekeXu
452次阅读
2025-04-01 15:56:03
【ORACLE】记录一些ORACLE的merge into语句的BUG
DarkAthena
442次阅读
2025-04-22 00:20:37
Oracle数据库一键巡检并生成HTML结果,免费脚本速来下载!
陈举超
425次阅读
2025-04-20 10:07:02
【ORACLE】你以为的真的是你以为的么?--ORA-38104: Columns referenced in the ON Clause cannot be updated
DarkAthena
417次阅读
2025-04-22 00:13:51
Oracle 19c RAC更换IP实战,运维必看!
szrsu
401次阅读
2025-04-08 23:57:08
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
372次阅读
2025-04-17 17:02:24