我通过以下代码成功使Oracle Advanced Queue出队:
OracleQueue oracleDequeueQueue = new OracleQueue("QUEUENAME", oracleConnection);
OracleQueueMessage msg = oracleDequeueQueue.Dequeue();
if (msg != null && msg.ObjectPayload != null)
{
Convert.ToString(msg.ObjectPayload["ID"])
}
当我尝试通过下一个代码片段收集队列数组时,我收到错误消息
System.Exception:'有效负载数据类型的收集类型 SCH.MDM_MESSAGE_TYPE不存在。'
OracleQueue oracleDequeueQueue = new OracleQueue("QUEUENAME", oracleConnection);
OracleQueueMessage[] msgArr = oracleDequeueQueue.DequeueArray(10);
foreach (OracleQueueMessage m in msgArr)
{
if (m != null && m.ObjectPayload != null)
{
Convert.ToString(m.ObjectPayload["ID"]));
}
}
我也尝试添加以下内容,但这也行不通:
oracleDequeueQueue.PayloadTypeName =“ SCH.MDM_MESSAGE_TYPE”; oracleDequeueQueue.PayloadArrayTypeName =“ SCH.MDM_MESSAGE_TYPE_ARRAY”;
我的代码有什么问题?
这是Oracle中的队列代码:
create or replace type mdm_message_type as object ( id number(12 ) );
create or replace TYPE mdm_message_type_array as table of mdm_message_type;
exec DBMS_AQADM.CREATE_QUEUE_TABLE( Queue_table => '"SCH"."MDM_CUSTOMER_T"', Queue_payload_type => 'SCH.MDM_MESSAGE_TYPE');
exec DBMS_AQADM.CREATE_QUEUE( Queue_name => 'SCH.MDM_CUSTOMER', Queue_table => 'SCH.MDM_CUSTOMER_T', Queue_type => 0, Max_retries => 10000, Retry_delay => 0, dependency_tracking => FALSE);
exec dbms_aqadm.start_queue( 'SCH.MDM_CUSTOMER',true,true);
答案 0 :(得分:0)
使用DequeueArray方法时,在Oracle中必须具有以下数组类型:
CREATE TYPE MESSAGE_ARRAY IS VARRAY (100) OF MESSAGE_TYPE_NAME
请注意,在Oracle中创建的MESSAGE_TYPE_NAME数组的长度应等于或大于.NET代码中DequeueArray方法中的参数值。