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

[pulsar-client] add api to wait for inflight messages while closing producer #6648

Closed
wants to merge 12 commits into from

Conversation

rdhabalia
Copy link
Contributor

Motivation

Right now, when user closes the producer, pulsar-client immediately fails inflight messages even if they persist successfully at the broker also most of the times users don't want to fail those messages rather user wants to wait for those inflight messages. Right now, pulsar-client lib doesn't provide a way to wait for inflight messages before closing the producer.

Modification

Add close API with the flag where user can control to wait for inflight messages.

Result

With this change user can close producer by waiting for inflight messages and pulsar-client will not fail those messages immediately.

@rdhabalia rdhabalia added this to the 2.6.0 milestone Apr 2, 2020
@rdhabalia rdhabalia self-assigned this Apr 2, 2020
@codelipenghui
Copy link
Contributor

@rdhabalia The CI failed related to the checkstyle, please take a look.

@merlimat
Copy link
Contributor

merlimat commented Apr 2, 2020

@rdhabalia The waiting for all the inflight messages should be the default current behavior (that's also what the javadoc says :) ). If that's not the case, then we should just fix the implementation but I don't think we need 2 options there.

@rdhabalia
Copy link
Contributor Author

@merlimat
Yes, I realized it and I already removed the API and fix the existing behavior as per java-doc. It failed many test cases so, now I have to fix them.

return closeAsync(false);
}

public CompletableFuture<Void> closeAsync(boolean waitForPendingMessages) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method can now be deleted


private void closeAsync(boolean waitForPendingMessage, CompletableFuture<Void> closeFuture) {
if (waitForPendingMessage && !pendingMessages.isEmpty()) {
CLOSING_IN_PROGRESS_UPDATER.set(this, TRUE);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're not using any compareAndSet() over the flag, then we won't need to use the updater.

return closeResult;
}

private void closeAsync(boolean waitForPendingMessage, CompletableFuture<Void> closeFuture) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't need the 2 new methods if we only care about the case waitForPendingMessage=true.

@sijie
Copy link
Member

sijie commented Apr 21, 2020

/pulsarbot run-failure-checks

@codelipenghui
Copy link
Contributor

@rdhabalia Could you please rebase the master branch?

@codelipenghui
Copy link
Contributor

ping @rdhabalia please rebase the branch.

@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

3 similar comments
@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

@codelipenghui
Copy link
Contributor

@rdhabalia Looks the failed CI tests related to this PR, could you please take a look? Or can we move it to 2.7.0 first?

@codelipenghui
Copy link
Contributor

move to 2.7.0 first.

…roducer

default closeAsync() should wait for inflight messages

address comments
@rdhabalia
Copy link
Contributor Author

/pulsarbot run-failure-checks

1 similar comment
@rdhabalia
Copy link
Contributor Author

/pulsarbot run-failure-checks

@codelipenghui
Copy link
Contributor

@rdhabalia Could you please also rebase this PR to apache/master?

@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

@codelipenghui
Copy link
Contributor

@rdhabalia Could you please help take a look at the failed test? looks related to this change.

@zymap
Copy link
Member

zymap commented Feb 23, 2021

Hi, @rdhabalia. It looks like this PR is opened for a long time, do we still need this? If we don't need this I will close this PR and remove the release/2.7.1 label.

@zymap
Copy link
Member

zymap commented Feb 25, 2021

Because this PR is opened for a long time. I will close this PR. Feel free to reopen it if you needed.

@zymap zymap closed this Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants