Skip to content
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

Add support for Pulsar default tenant/namespace #41851

Closed
wants to merge 7 commits into from

Conversation

onobc
Copy link
Contributor

@onobc onobc commented Aug 14, 2024

This commit allows Pulsar users to configure a default tenant and/or namespace to be used when producing or consuming messages to topic URLs that are not fully-qualified.

The following changes accomplish this:

  • add tenant and namespace config props to spring.pulsar.defaults
  • auto-configure a PulsarTopicBuilder bean populated w/ above props
  • provide above topic builder to producer/consumer/reader factories (imperative and reactive)
  • add tests for all of the above

This commit allows Pulsar users to configure a default tenant
and/or namespace to be used when producing or consuming messages
to topic URLs that are not fully-qualified.

The following changes accomplish this:
- add `tenant` and `namespace` config props to `spring.pulsar.defaults`
- auto-configure a `PulsarTopicBuilder` bean populated w/ above props
- provide above topic builder to producer/consumer/reader factories
  (imperative and reactive)
- add tests for all of the above
onobc added 3 commits August 14, 2024 11:33
The builder is stateful and as such each injection point
needs its own bean instance.
Comment on lines 253 to 266
/**
* Default tenant to use when producing or consuming messages against a
* non-fully-qualified topic URL. When not specified Pulsar uses a default tenant
* of 'public'.
*/
private String tenant;

/**
* Default namespace to use when producing or consuming messages against a
* non-fully-qualified topic URL. When not specified Pulsar uses a default
* namespace of 'default'.
*/
private String namespace;

Copy link
Member

Choose a reason for hiding this comment

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

As these properties both relate to topics, it would be good to put them both in a topic group so they'd become spring.pulsar.defaults.topic.tenant and spring.pulsar.defaults.topic.namespace. I think that still makes sense given that typeMappings is partially topic related. What do you think though, @cbono?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion as this also gives way to adding an enabled flag to the spring.pulsar.defaults.topic to disable default topics if so desired.

@wilkinsona wilkinsona self-assigned this Aug 19, 2024
@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 19, 2024
@wilkinsona wilkinsona modified the milestones: 3.4.x, 3.4.0-M2 Aug 19, 2024
wilkinsona pushed a commit that referenced this pull request Aug 20, 2024
This commit allows Pulsar users to configure a default tenant
and/or namespace to be used when producing or consuming messages
to topic URLs that are not fully-qualified.

See gh-41851
wilkinsona added a commit that referenced this pull request Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants