Oracle Advanced Queue - 出队后删除消息

Oracle Advanced Queue - Removing Message after Dequeue

我们正在使用 Oracle JMS API 从 Advanced Queue 中读取消息。我们使用以下代码从队列中读取消息:

    MessageConsumer consumer = sess.createConsumer(q);


    for (Message m; (m = consumer.receive()) != null;) 
    {
          new Timer().schedule(new QueueExample(m), 0);
    }

问题是,从队列中接收到消息后,并没有完全从队列中移除table,只是STATE字段从0变成了2。这是默认行为吗Oracle JMS 客户端?在使用 consumer.receive() 方法从队列中读取消息后,我们希望从队列 table 中完全删除记录。什么是适当的 api 方法来做到这一点?

我认为您遇到此问题是因为您队列上的 retention_time 参数被配置 为某个高值。

保留用于:

Users can specify that messages be retained after consumption. The systems administrator can specify the duration for which messages will be retained. Oracle AQ stores information about the history of each message, preserving the queue and message properties of delay, expiration, and retention for messages destined for local or remote recipients. The information contains the ENQUEUE/DEQUEUE time and the identification of the transaction that executed each request. This allows users to keep a history of relevant messages. The history can be used for tracking, data warehouse and data mining operations.

您可以通过检查队列创建脚本并通过管理界面或使用 ALTER_QUEUE 更改设置来验证这一点。