Skip to content

Add hasResponded check to Message#84

Open
ravisanwal wants to merge 3 commits intomainfrom
DFZ-1343
Open

Add hasResponded check to Message#84
ravisanwal wants to merge 3 commits intomainfrom
DFZ-1343

Conversation

@ravisanwal
Copy link
Copy Markdown

This adds the capability to check if a message has been responded to, by finish or requeue. It also makes these operations idempotent and NOOP after the first attempt.

In addition to this, it also makes touch a NOOP when a message has already been responded to.

Callers can now unconditinally finish or requeue without being concerned about any acknowledgemnt that has happened before. Or they can simply check if a message has been responded to or not.

For backwards-compatility, the interface method defaults to returning false.

This adds the capability to check if a message has been responded to, by `finish` or `requeue`.
It also makes these operations idempotent and NOOP after the first attempt.

In addition to this, it also makes `touch` a NOOP when a message has already been responded to.

Callers can now unconditinally `finish` or `requeue` without being concerned about any acknowledgemnt that has happened before.
Or they can simply check if a message has been responded to or not.

For backwards-compatility, the interface method defaults to returning `false`.
void forceFlush();

default boolean hasResponded() {
return false;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't think I like a default for this.

private final byte[] data;
private final String topic;
private final SubConnection connection;
private final AtomicBoolean responded = new AtomicBoolean();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I wonder if we want more granular information about the final state of the message like was it finished, requeued, etc.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@chrisparrinello this is mostly for bringing our library at-par (with respect to this feature) with other ones (go/python)
Adding more granular status, while may be desirable, is a bit out of scope.

blakesmith
blakesmith previously approved these changes Sep 11, 2024
Copy link
Copy Markdown
Contributor

@blakesmith blakesmith left a comment

Choose a reason for hiding this comment

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

Looks good to me. Extra semicolon nit, but I think this works.

public void requeue(int delayMillis) {
connection.requeue(id, delayMillis);
if (responded.compareAndSet(false, true)) {
connection.requeue(id, delayMillis);;
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.

nit: Extra semicolon.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants