You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When transaction is configured for the `PostgresSubscribableChannel.notifyUpdate()`
and it is rolled back, the next poll in that loop will return the same message.
Again and again if transaction is always rolled back.
This leads to the condition when we never leave this loop even if
we fully unsubscribed from this channel.
The issue has need spotted after introducing `SKIP LOCKED`
for `PostgresChannelMessageStoreQueryProvider` which leads to
the locked record in DB in the mentioned above transaction.
* Introduce `PostgresSubscribableChannel.hasHandlers` flag
to check in the `notifyUpdate()` before performing poll query in DB.
**Cherry-pick to `6.1.x` & `6.0.x`**
Copy file name to clipboardExpand all lines: spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/channel/PostgresSubscribableChannel.java
+19-12Lines changed: 19 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,8 @@ public class PostgresSubscribableChannel extends AbstractSubscribableChannel
67
67
68
68
privateExecutorexecutor;
69
69
70
+
privatevolatilebooleanhasHandlers;
71
+
70
72
/**
71
73
* Create a subscribable channel for a Postgres database.
72
74
* @param jdbcChannelMessageStore The message store to use for the relevant region.
@@ -128,6 +130,7 @@ public boolean subscribe(MessageHandler handler) {
128
130
booleansubscribed = super.subscribe(handler);
129
131
if (this.dispatcher.getHandlerCount() == 1) {
130
132
this.messageTableSubscriber.subscribe(this);
133
+
this.hasHandlers = true;
131
134
notifyUpdate();
132
135
}
133
136
returnsubscribed;
@@ -138,6 +141,7 @@ public boolean unsubscribe(MessageHandler handle) {
Copy file name to clipboardExpand all lines: spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/channel/PostgresChannelMessageTableSubscriberTests.java
0 commit comments