-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Hi,
We recently faced serious performance issues with spring-integration-jdbc:5.0.7 and PostgreSQL 9.5.13.
With DB backed queue containing over 1.8 million messages, the average speed of processing stored data was 2messages per second. After a long investigation we found out, that problem was caused by the function polling messages and more precisely part checking the size of the queue.
For millions of records MessageGroupQueue.size method called following SQL from AbstractChannelMessageStoreQueryProvider.getCountAllMessagesInGroupQuery:
SELECT COUNT(MESSAGE_ID) from %PREFIX%CHANNEL_MESSAGE where GROUP_KEY=? and REGION=?
which could take even few seconds to complete (see: slow counting).
Quick fix:
Our workaround consisted on extending PostgresChannelMessageStoreQueryProvider.getCountAllMessagesInGroupQuery method to use faster count method using approach similar to presented here: fast count.
Improvement suggestion
I would suggest changing following part of MessageGroupQueue.poll:
try {
while (this.size() == 0 && timeoutInNanos > 0) {
timeoutInNanos = this.messageStoreNotEmpty.awaitNanos(timeoutInNanos);
}
message = this.doPoll();
}
to use new method this.isEmpty(), which for PosgresSQL can run following query:
select exists(select 1 from %PREFIX%channel_message where GROUP_KEY=? and REGION=?)
Using our workaround seems to be not the best solution as it returns only estimated value.
Regards, Kamil
PS. It may be connected to #2628 issue