-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[improve][client] Add newMessage with schema and transactions #23942
base: master
Are you sure you want to change the base?
Conversation
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Producer.java
Show resolved
Hide resolved
For PIP process, pls referring to https://github.com/apache/pulsar/tree/master/pip#pulsar-improvement-proposal-pip |
PIP PR filed here: #23950, will follow those guidelines by emailing out to the thread soon, etc. |
Pulsar Client allows callers to create messages with a schema or a transaction, but not both. This commit adds a new method in the producer that allows callers to create a message with both a schema and transaction.
d77ad02
to
59dd60a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@BewareMyPower @dao-jun The PIP has been approved and merged, https://github.com/apache/pulsar/blob/master/pip/pip-407.md . PTAL and review |
<V> TypedMessageBuilder<V> newMessage(Schema<V> schema, | ||
Transaction txn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a concern about backward compatibility with this interface change. Adding a new method without a default implementation will break source compatibility for any custom implementations of the Producer
interface.
While it might be uncommon for users to implement this interface directly, it could happen in testing scenarios or custom proxy implementations. Java source compatibility rules require all implementors to provide all interface methods.
We could address the source compatibility issue by adding a default implementation:
<V> TypedMessageBuilder<V> newMessage(Schema<V> schema, | |
Transaction txn); | |
default <V> TypedMessageBuilder<V> newMessage(Schema<V> schema, Transaction txn) { | |
// to retain source compatibilty of Producer interface for implementors of the Producer interface | |
throw new UnsupportedOperationException( | |
String.format("Method not implemented in: %s", getClass().getName())); | |
} |
The benefit of making it source compatible is that we could also backport this change to the 4.0.x client without introducing breaking changes.
Pulsar Client allows callers to create messages with a schema or a transaction, but not both.
This commit adds a new method in the producer that allows callers to create a message with both a schema and transaction.
Documentation
doc
doc-required
doc-not-needed
doc-complete