Skip to content

Enable multiple event listeners to consume for Polaris events#3973

Merged
flyrain merged 15 commits intoapache:mainfrom
nandorKollar:multiple_event_listener_service_bus
Mar 25, 2026
Merged

Enable multiple event listeners to consume for Polaris events#3973
flyrain merged 15 commits intoapache:mainfrom
nandorKollar:multiple_event_listener_service_bus

Conversation

@nandorKollar
Copy link
Copy Markdown
Contributor

@nandorKollar nandorKollar commented Mar 11, 2026

This PR enables multiple event listeners watching for Polaris events.

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

@nandorKollar
Copy link
Copy Markdown
Contributor Author

nandorKollar commented Mar 11, 2026

@jbonofre @adutra @adnanhemani would you mind share your thoughts about this approach?

@jbonofre jbonofre self-requested a review March 11, 2026 13:58
@nandorKollar nandorKollar force-pushed the multiple_event_listener_service_bus branch 7 times, most recently from d0242ed to 09c5600 Compare March 11, 2026 19:59
@nandorKollar nandorKollar force-pushed the multiple_event_listener_service_bus branch from 09c5600 to aad3caf Compare March 11, 2026 20:13
@adutra adutra mentioned this pull request Mar 13, 2026
6 tasks
Copy link
Copy Markdown
Contributor

@adutra adutra left a comment

Choose a reason for hiding this comment

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

@nandorKollar this is look promising thanks!

I think we should avoid calling dispatch() altogether (and avoid materializing the PolarisEvent instance on the heap) if we know the event type is not needed. I would like us to consider that, if a user deactivates all listeners, they would get a performance comparable to what they would get if there were no events in Polaris at all.

@nandorKollar nandorKollar force-pushed the multiple_event_listener_service_bus branch from 8b05fcf to 1c71676 Compare March 14, 2026 20:20
public void onStartup(@Observes StartupEvent event) {
String listerTypes = configuration.types().orElse("");
if (listerTypes.isBlank()) {
return;
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.

If we don't have types here, it means we never reach type() merging bellow (line 51).

If a user only set polaris.event-listener.type (the old config) without setting types, the onStartup() method just returns directly, and no listener is registered.

It means it's a breaking change.

Imho, the type() merge logic should be before the early return, or this check should check both types and type (to be backward compatible).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, thanks! This is indeed broken, fixed in 1a0aaa5

* Comma separated list of event listers, each item must be a registered {@link
* PolarisEventListener} identifier.
*/
Optional<String> types();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Optional<String> types();
Optional<List<String>> types();

It's a bit odd to see an Optional<List<...> – but that's how SmallRye Config wants it 😅

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Update: Optional<Set<String>> types(); is probably better.

@nandorKollar nandorKollar force-pushed the multiple_event_listener_service_bus branch from 48b5fbd to c9f843b Compare March 16, 2026 22:43
Comment thread runtime/defaults/src/main/resources/application.properties
@nandorKollar nandorKollar force-pushed the multiple_event_listener_service_bus branch from ee21f22 to 716f6db Compare March 16, 2026 23:13
@nandorKollar
Copy link
Copy Markdown
Contributor Author

@nandorKollar this is look promising thanks!

I think we should avoid calling dispatch() altogether (and avoid materializing the PolarisEvent instance on the heap) if we know the event type is not needed. I would like us to consider that, if a user deactivates all listeners, they would get a performance comparable to what they would get if there were no events in Polaris at all.

Thanks, this makes sense, however I've further questions related to this. Do you happen to know why does AwsCloudWatchEventListener filter only for a single event type? I think event listeners should accept any event type, and allow users to configure a particular event listener to listen for only a certain events, but the listener code itself should not assume that it is working only with event type xyz.

@nandorKollar nandorKollar marked this pull request as ready for review March 17, 2026 07:22
@adutra
Copy link
Copy Markdown
Contributor

adutra commented Mar 17, 2026

Do you happen to know why does AwsCloudWatchEventListener filter only for a single event type? I think event listeners should accept any event type, and allow users to configure a particular event listener to listen for only a certain events, but the listener code itself should not assume that it is working only with event type xyz.

Completely agree here. Listeners should NOT filter events, and especially not in a hard-coded fashion – that's a user decision. @adnanhemani may know why the CoudWatch listener was designed that way. Imho it's not very useful – it can only be useful if you are interested in after-refresh-table events, and hence, in certain table optimization use cases.

Copy link
Copy Markdown
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

Sorry about last minute comments. The PR LGTM overall. My only suggestion is to try and add automatic redirects for the old config name.

@nandorKollar nandorKollar force-pushed the multiple_event_listener_service_bus branch from 16170de to b570a2e Compare March 20, 2026 13:16
…er_service_bus

# Conflicts:
#	runtime/service/src/main/java/org/apache/polaris/service/config/ServiceProducers.java
@flyrain flyrain requested a review from adnanhemani March 21, 2026 06:34
Comment thread CHANGELOG.md Outdated

- The configuration option `polaris.rate-limiter.token-bucket.window` is no longer supported and should be removed.
- `PolarisConfigurationStore` has been deprecated for removal.
- The configuration option `polaris.event-listener.type` is no longer supported and should be removed. Please use `polaris.event-listener.types` instead.
Copy link
Copy Markdown
Contributor

@flyrain flyrain Mar 21, 2026

Choose a reason for hiding this comment

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

It mighty be OK to make this breaking change, given event listener are not widely used ATM. Could we share it in the mailing list to gather more feedback to double check? cc @adnanhemani .

If it turns out to be fine, we should call it out here that it's a breaking change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NVM. It seems to be deprecated. I think the word here isn't accurate.

Suggested change
- The configuration option `polaris.event-listener.type` is no longer supported and should be removed. Please use `polaris.event-listener.types` instead.
- The configuration option `polaris.event-listener.type` is deprecated and will be removed later. Please use `polaris.event-listener.types` instead.

Copy link
Copy Markdown
Contributor

@flyrain flyrain left a comment

Choose a reason for hiding this comment

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

Thanks @nandorKollar for working on it. Can we add test to configure polaris.event-listener.types with 2+ listeners (e.g., 'test,in-memory-buffer') and verify all receive events? Can we add test to verify deprecated polaris.event-listener.type still works?

@jbonofre jbonofre changed the title Enable multiple event listers to consume for Polaris events Enable multiple event listeners to consume for Polaris events Mar 22, 2026
@jbonofre
Copy link
Copy Markdown
Member

nit: I updated the PR title (typo on lister instead of listener 😄 ).

@nandorKollar nandorKollar requested review from dimas-b and flyrain March 23, 2026 09:51
dimas-b
dimas-b previously approved these changes Mar 23, 2026
Copy link
Copy Markdown
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

LGTM, pending resolution of open comment threads 👍 Thanks, @nandorKollar !

@nandorKollar
Copy link
Copy Markdown
Contributor Author

Great, thanks @dimas-b , @flyrain would you mind also have a look at the latest version? @jbonofre @adutra is there any unresolved comment on your end that I may have forgotten to address?

@adnanhemani
Copy link
Copy Markdown
Contributor

I will look into this later today, please hold merging until then.

Copy link
Copy Markdown
Contributor

@adnanhemani adnanhemani left a comment

Choose a reason for hiding this comment

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

Looks almost there, just a few questions on my end - and then one comment from @flyrain about adding a Javadoc. Will approve it after those are done!


@ApplicationScoped
public class EventBusConfigurer {
private static final String LOCAL_CODEC_NAME = "local";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not an expert but after searching around, it seems like this value is supposed to be unique per codec. So shouldn't we name this something like "polaris-events-local" or something to ensure there is no potential future clash naming-wise?

@nandorKollar
Copy link
Copy Markdown
Contributor Author

Looks almost there, just a few questions on my end - and then one comment from @flyrain about adding a Javadoc. Will approve it after those are done!

@adnanhemani which Javadoc do you refer to? I already added Javadoc to PolarisServiceBusEventDispatcher.

Copy link
Copy Markdown
Contributor

@adnanhemani adnanhemani left a comment

Choose a reason for hiding this comment

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

Thank you for this @nandorKollar!

@nandorKollar nandorKollar requested a review from dimas-b March 24, 2026 13:04
Copy link
Copy Markdown
Contributor

@flyrain flyrain left a comment

Choose a reason for hiding this comment

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

Thanks @nandorKollar !

@flyrain flyrain merged commit e94fdff into apache:main Mar 25, 2026
18 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Mar 25, 2026
@nandorKollar
Copy link
Copy Markdown
Contributor Author

Thank you all for the help and reviews!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants