WARN JdbcChannelMessageStore 带有 id 的消息未被删除

WARN JdbcChannelMessageStore Message with id was not deleted

我有一个由 JdbcChannelMessageStore 支持的队列通道。我有这个应用程序的两个实例,在高并发情况下我有这个警告:

2020-03-13 19:25:38,209 task-scheduler-5  WARN JdbcChannelMessageStore:652 - Message with id '06b73eab-727a-780f-d0fa-1b0e0dd1ea20' was not deleted.

有没有办法删除它们?

据我了解,消息被阅读了两次,我说得对吗?

我正在使用 SI 4.3。19.RELEASE。这是我的spring流程

<int:channel id="channel">
        <int:queue message-store="messageStoreBean"/>
</int:channel>

<int:header-value-router input-channel="channel 
        header-name="name" >
        <int:poller max-messages-per-poll="2" fixed-rate="500" >
            <int:transactional />
        </int:poller>
        ...
</int:header-value-router>

<bean id="storeQueryProviderBean" class="org.springframework.integration.jdbc.store.channel.PostgresChannelMessageStoreQueryProvider" />

    <bean id="messageStoreBean" class="org.springframework.integration.jdbc.store.JdbcChannelMessageStore">
        <property name="dataSource" ref="messageStoreDataSource" />
        <property name="channelMessageStoreQueryProvider" ref="storeQueryProviderBean" />
        <property name="region" value="region" />
    </bean>

看起来 PostgreSQL 不保证事务的独占读取和 LIMIT 1 FOR UPDATE

无论如何,WARN 只是一个提示,表明其他进程已删除该消息。如果其他进程与该轮询器相似,则不会重复任何内容:

public Message<?> pollMessageFromGroup(Object groupId) {

    final String key = getKey(groupId);
    final Message<?> polledMessage = this.doPollForMessage(key);

    if (polledMessage != null) {
        if (!this.doRemoveMessageFromGroup(groupId, polledMessage)) {
            return null;
        }
    }

    return polledMessage;
}

你看看消息是否没有被删除,我们 return null 因此目前没有什么可轮询的。

您可以关闭 org.springframework.integration.jdbc.store.JdbcChannelMessageStore 的警告级别,以避免该消息在您的日志配置中将类别级别指定为 ERROR