在生产环境中,我们在将消息出列时时不时会收到 ORA-0001 错误。我们用:
- 索拉里斯 10
- 甲骨文 10g
- C++ 应用程序
- 带有 dbms_aq 包的 PROC*C 用于排队操作
- 带有 XML 负载的队列
- 我们处理大量消息(1K/分钟)。
任何线索为什么出队会导致 ORA-0001(唯一约束)错误?
更新:每个请求添加代码。
EXEC SQL EXECUTE
DECLARE
message_properties dbms_aq.message_properties_t;
dequeue_options dbms_aq.dequeue_options_t;
message_payload xmltype;
tmpclob clob;
dynamic_sql_string varchar2(512);
BEGIN
dequeue_options.wait := :iReadTimeout;
dequeue_options.dequeue_mode := dbms_aq.REMOVE;
dequeue_options.visibility := dbms_aq.ON_COMMIT;
IF :iBuffered = 1 then
dequeue_options.delivery_mode := dbms_aq.buffered;
dequeue_options.visibility := dbms_aq.immediate;
:iNavigationMode := 0;
END IF;
IF :iDequeueOnly = 1 and :iQueueType <> 1 THEN
dequeue_options.dequeue_mode := dbms_aq.REMOVE_NODATA;
dequeue_options.wait := dbms_aq.NO_WAIT;
dequeue_options.msgid := hextoraw(:pszDequeueMsgId);
ELSE
IF :iNavigationMode = 0 THEN
dequeue_options.navigation := dbms_aq.FIRST_MESSAGE;
ELSE
dequeue_options.navigation := dbms_aq.NEXT_MESSAGE;
END IF;
END IF;
dequeue_options.deq_condition := :pszDeqCondition;
dbms_aq.dequeue(queue_name => :pszQueueName,
message_properties => message_properties,
dequeue_options => dequeue_options,
payload => message_payload,
msgid => :msgid );
IF dequeue_options.dequeue_mode <> dbms_aq.REMOVE_NODATA THEN
EXECUTE IMMEDIATE dynamic_sql_string USING OUT tmpclob, IN message_payload;
:gpoXmlClob := tmpclob;
ELSE
:gpoXmlClob := message_payload.getclobval();
END IF;
END;