Skip to content

Update RedisOperations#convertAndSend to return number of clients receiving the message. #2225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

vpavic
Copy link

@vpavic vpavic commented Jan 5, 2022

Currently, RedisOperations#convertAndSend is void event though the underlying RedisPubSubCommands#publish returns a Long that represents the number of clients receiving the published message (see https://redis.io/commands/publish).

This commit updates RedisOperations#convertAndSend to return the number of clients that received the message.

Closes #2209

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

…eceiving the message.

Currently, `RedisOperations#convertAndSend` is void event though the underlying `RedisPubSubCommands#publish` returns a `Long` that represents the number of clients receiving the published message (see https://redis.io/commands/publish).

This commit updates `RedisOperations#convertAndSend` to return the number of clients that received the message.

Closes spring-projects#2209
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 5, 2022
// test no messages are sent just to patterns
template.convertAndSend(CHANNEL, payload1);
template.convertAndSend(ANOTHER_CHANNEL, payload2);
await().atMost(Duration.ofMillis(600)).untilAsserted(() -> {
Copy link
Author

Choose a reason for hiding this comment

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

I utilized Awaitility in use cases like this as it's more handy vs having to resort to Thread#sleep. Note that for this particular set of assertions I had to increase the grace period from 400 to 600 ms as the test was flaky, on my machine at least.

@christophstrobl christophstrobl added theme: 4.0 type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 28, 2022
@mp911de
Copy link
Member

mp911de commented Mar 31, 2022

We're considering this change for the next Spring Data Redis 3.0 milestone.

@mp911de mp911de added this to the 3.0 M4 (2022.0.0) milestone Mar 31, 2022
mp911de pushed a commit that referenced this pull request Mar 31, 2022
…eceiving the message.

Currently, `RedisOperations#convertAndSend` is void event though the underlying `RedisPubSubCommands#publish` returns a `Long` that represents the number of clients receiving the published message (see https://redis.io/commands/publish).

This commit updates `RedisOperations#convertAndSend` to return the number of clients that received the message.

Closes #2209
Original pull request: #2225.
mp911de added a commit that referenced this pull request Mar 31, 2022
Reformat code. Refine tests as we do not require assertions for every publish command when testing listeners.

See #2209
Original pull request: #2225.
@mp911de
Copy link
Member

mp911de commented Mar 31, 2022

Thank you for your contribution. That's merged and polished now.

@mp911de mp911de closed this Mar 31, 2022
@vpavic vpavic deleted the gh-2209 branch March 31, 2022 08:30
mp911de added a commit that referenced this pull request Mar 31, 2022
Refine tests as we do not require assertions for every publish command when testing listeners.

See #2209
Original pull request: #2225.
mp911de added a commit that referenced this pull request Mar 31, 2022
Refine tests as we do not require assertions for every publish command when testing listeners.

See #2209
Original pull request: #2225.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: 4.0 type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update RedisOperations#convertAndSend to return number of subscribers
4 participants