Skip to content

GH-3429: Expose non-destructive channel store message reads - #11597

Open
2748109647 wants to merge 3 commits into
spring-projects:mainfrom
2748109647:GH-3429
Open

2748109647 wants to merge 3 commits into
spring-projects:mainfrom
2748109647:GH-3429

Conversation

@2748109647

@2748109647 2748109647 commented Oct 24, 2026 •

Copy link
Copy Markdown

Fixes #3429.

Channel stores cannot currently expose non-destructive message reads through their shared API, and JDBC returns an empty message group even when the channel contains messages.

Promote getMessagesForGroup() and streamMessagesForGroup() to BasicMessageGroupStore, with defaults for existing implementations. Add JDBC inspection queries that reuse the configured query provider, row mapper, table prefix, group key, and region. Derive an unlimited inspection template without changing the polling template's row limit or other settings.

JDBC's default factory returns lazy groups so inserts do not read the entire queue. Retain the existing MessageGroupStore factory overloads and add a basic-store overload. Inspection uses creation/sequence order, leaves FIFO and priority polling unchanged, and does not reserve messages against concurrent consumers. Document transaction visibility and stream ownership.

Regression coverage includes non-destructive reads, lazy group creation, group/region isolation, priority polling after inspection, JSON row mapping with a custom table prefix, and connection release after partial stream consumption.

Validation on JDK 25 in Linux Docker: the complete test task passed across 44 modules (6,107 passed, 112 skipped, zero failures), together with core/JDBC main and test Checkstyle. Local verification init scripts supplied the pinned Linux protobuf binaries, the Mockito agent, and a scripting JVM option to avoid the image's incompatible libgraal; a TCP forwarder made Testcontainers' published ports reachable from the build container. These environment helpers are outside the PR.

Redis follow-up

  • RedisChannelMessageStore and RedisChannelPriorityMessageStore now use persistent message groups, fetching contents only when read. The priority store aggregates priority keys in polling order.
  • Added tests that create a group before adding messages, verify lazy reads include the later messages, and confirm priority reads do not consume them.

Focused validation on this updated branch passed: ./gradlew :spring-integration-redis:compileTestJava and ./gradlew :spring-integration-redis:test --tests org.springframework.integration.redis.store.RedisChannelMessageStoreTests.

…reads

Fixes: spring-projects#3429

Channel stores cannot expose inspection through their shared API, and JDBC
returns an empty message group even when messages are queued.

* Promote collection and stream reads to BasicMessageGroupStore
* Add JDBC queries with group/region isolation and the configured row mapper
* Derive an unlimited inspection template without changing polling settings
* Keep default JDBC groups lazy and preserve the existing factory overloads
* Verify non-destructive reads, ordering, isolation and stream cleanup

Signed-off-by: 樊孔缘 <[email protected]>

@artembilan artembilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!
Please, mention this change in the x7.2-jdbc-changes section of the whats-new.adoc.

I am mostly worried about your name being ruined due to encoding changes between different operating systems or so.

Thank you!

*
* @author Gary Russell
* @author Artem Bilan
* @author 樊孔缘

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, consider to use only Latin symbols for your name.

/**
* Tests for non-destructive access through the basic store contract.
*
* @author 樊孔缘

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also prefer @since for new test classes.
Not their methods, though 😄

== Inspecting Stored Channel Messages

Starting with version 7.2, `getMessagesForGroup(groupId)` and `streamMessagesForGroup(groupId)`
are available through `BasicMessageGroupStore`, including `ChannelMessageStore`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* By default, obtains the messages from {@link #getMessageGroup(Object)}.
* @param groupId the group id to retrieve messages for.
* @return the messages for the group, empty if none exists.
* @since 7.2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole new feature will go to the next 7.3 version.
Please, revise all the new @since in your change set.

Thank you!

@2748109647

Copy link
Copy Markdown
Author

Addressed in commit 8bca552.

  • Converted the new @author entries to Latin characters (Fan Kongyuan).
  • Updated all newly added @SInCE tags, including the new test class, to 7.3.
  • Reflowed the documentation to one sentence per line and changed the feature introduction to 7.3.
  • Added the required Signed-off-by trailer using the same contributor identity as the existing PR commit.

Validation: git diff --check, core/JDBC main and test Checkstyle, and test compilation passed. I could not execute the tests locally: the Mockito/ByteBuddy javaagent fails to launch from the Windows path containing Chinese characters. I have not treated that as a passing test run.

I did not add the earlier requested entry to x7.2-jdbc-changes because you clarified that the feature will be in 7.3; the current whats-new page has no 7.3 section yet.

@artembilan artembilan added the status: next Mark accepted PR but for the next major/minor label Oct 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: next Mark accepted PR but for the next major/minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide access to stored messages from the ChannelMessageStore API

2 participants