-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix] [broker] Make specified producer could override the previous one #21155
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
Changes from all commits
5f74e48
a5ba726
8916452
2136266
66491fe
3b968ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -982,8 +982,7 @@ protected void internalAddProducer(Producer producer) throws BrokerServiceExcept | |
|
|
||
| private void tryOverwriteOldProducer(Producer oldProducer, Producer newProducer) | ||
| throws BrokerServiceException { | ||
| if (newProducer.isSuccessorTo(oldProducer) && !isUserProvidedProducerName(oldProducer) | ||
| && !isUserProvidedProducerName(newProducer)) { | ||
| if (newProducer.isSuccessorTo(oldProducer)) { | ||
| oldProducer.close(false); | ||
| if (!producers.replace(newProducer.getProducerName(), oldProducer, newProducer)) { | ||
| // Met concurrent update, throw exception here so that client can try reconnect later. | ||
|
|
@@ -993,6 +992,11 @@ private void tryOverwriteOldProducer(Producer oldProducer, Producer newProducer) | |
| handleProducerRemoved(oldProducer); | ||
| } | ||
| } else { | ||
| // If a producer with the same name tries to use a new connection, async check the old connection is | ||
| // available. The producers related the connection that not available are automatically cleaned up. | ||
| if (!Objects.equals(oldProducer.getCnx(), newProducer.getCnx())) { | ||
| oldProducer.getCnx().checkConnectionLiveness(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This returns a future that can be used to prevent unnecessary exceptions. Did you consider wiring that up?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I submitted a new PR to improve this behavior. Please help to review it |
||
| } | ||
| throw new BrokerServiceException.NamingException( | ||
| "Producer with name '" + newProducer.getProducerName() + "' is already connected to topic"); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.