使用 ODP.net 出列后,Oracle Advanced Queue 的消息状态未更新

Message State of Oracle Advanced Queue not updating after Dequeue using ODP.net

我正尝试通过服务ODP.NET从 oracle AQ 中取出一条消息

一旦服务使消息出列,该记录不应该可用于其他服务实例,意味着它应该被锁定直到事务提交或事务过期

我的问题是我能够成功地使记录出列但是消息状态没有从就绪状态更新到任何其他状态,我也能够获得有效负载数据

 Public Shared Sub DequeueMessage(ByVal MessageID As String)
        Dim constr As String = "mystring"
        Dim con As Oracle.DataAccess.Client.OracleConnection = New Oracle.DataAccess.Client.OracleConnection(constr)
        Dim queue As OracleAQQueue = New OracleAQQueue("MyQueuname", con)

        Try
            con.Open()
            Dim oracleCommand As OracleCommand = New OracleCommand("Select MSGID  from INTEGRATION_MSG_QUEUE where msgid='B85439241C9241A4A6B1869F08F382E7'", con)
            Dim K = oracleCommand.ExecuteScalar()
            Dim rawBytesFromOracle As Byte() = TryCast(K, Byte())
            Dim txn As Oracle.DataAccess.Client.OracleTransaction = con.BeginTransaction()
            queue.DequeueOptions.Visibility = OracleAQVisibilityMode.OnCommit
            queue.DequeueOptions.Wait = 0
            queue.DequeueOptions.DequeueMode = OracleAQDequeueMode.Locked
            queue.DequeueOptions.MessageId = rawBytesFromOracle
            queue.MessageType = OracleAQMessageType.Udt
            queue.UdtTypeName = "TRIGGER_AUDIT_TYPE"
            Dim deqMsg As OracleAQMessage = queue.Dequeue()
            Dim data As TRIGGER_AUDIT_TYPE = CType(deqMsg.Payload, TRIGGER_AUDIT_TYPE)
            Console.WriteLine("Dequeued message...." & data.CMESSAGEBODY) ''Iam getting data here
            txn.Commit()
        Catch e As Exception
            Console.WriteLine("Error: {0}", e.Message)
        Finally
            con.Close()
            con.Dispose()
        End Try
    End Sub

我的队列就像

BEGIN DBMS_AQADM.CREATE_QUEUE_TABLE(
     Queue_table        => '"instance"."INTEGRATION_MSG_QUEUE"',
     Queue_payload_type => '"instance"."TRIGGER_AUDIT_TYPE"',
     Sort_list          => 'ENQ_TIME',
     Compatible         => '10.0.0',
     primary_instance   => 3,
     secondary_instance => 2);
  END;
  
   BEGIN DBMS_AQADM.CREATE_QUEUE(
     Queue_name          => '"instance"."INTEGRATION_MSG_QUEUE_Q"',
     Queue_table         => '"instance"."INTEGRATION_MSG_QUEUE"',
     Queue_type          =>  0,
     Max_retries         =>  5,
     Retry_delay         =>  0,
     dependency_tracking =>  FALSE);
  END;

谁能指出我做错了什么

您需要将其出队:

queue.DequeueOptions.DequeueMode = OracleAQDequeueMode.Remove

或:

queue.DequeueOptions.DequeueMode = OracleAQDequeueMode.RemoveNoData

当您使用Locked模式时,您只是在浏览并获得对消息的锁定。你需要实际更新它。

见: https://docs.oracle.com/cd/E11882_01/win.112/e23174/OracleAQDequeueModeEnumeration.htm#ODPNT3687