-
Notifications
You must be signed in to change notification settings - Fork 27
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 hasResponded check to Message #84
base: main
Are you sure you want to change the base?
Conversation
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`.
@@ -22,4 +22,8 @@ public interface Message { | |||
|
|||
void forceFlush(); | |||
|
|||
default boolean hasResponded() { | |||
return false; |
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 don't think I like a default for this.
@@ -10,6 +11,7 @@ class NSQMessage implements Message { | |||
private final byte[] data; | |||
private final String topic; | |||
private final SubConnection connection; | |||
private final AtomicBoolean responded = new AtomicBoolean(); |
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 wonder if we want more granular information about the final state of the message like was it finished, requeued, etc.
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.
@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.
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.
Looks good to me. Extra semicolon nit, but I think this works.
} | ||
|
||
@Override | ||
public void requeue(int delayMillis) { | ||
connection.requeue(id, delayMillis); | ||
if (responded.compareAndSet(false, true)) { | ||
connection.requeue(id, delayMillis);; |
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.
nit: Extra semicolon.
95d8761
This adds the capability to check if a message has been responded to, by
finish
orrequeue
. 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
orrequeue
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
.