-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
17 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
|
||
# https://docs.nats.io/using-nats/developer/develop_jetstream/model_deep_dive#acknowledgement-models | ||
|
||
const CONSUMER_ACK_OPTIONS = [ "+ACK", "-NAK", "+WPI", "+NXT", "+TERM" ] | ||
|
||
""" | ||
$(SIGNATURES) | ||
Confirms message delivery to server. | ||
""" | ||
function consumer_ack(connection::NATS.Connection, msg::NATS.Msg; delays = DEFAULT_API_CALL_DELAYS) | ||
function consumer_ack(connection::NATS.Connection, msg::NATS.Msg, ack::String = "+ACK"; delays = DEFAULT_API_CALL_DELAYS) | ||
ack in CONSUMER_ACK_OPTIONS || error("Unknown ack type \"$ack\", allowed values: $(join(CONSUMER_ACK_OPTIONS, ", "))") | ||
isnothing(msg.reply_to) && error("No reply subject for msg $msg.") | ||
!startswith(msg.reply_to, "\$JS.ACK") && @warn "`ack` sent for message that doesn't need acknowledgement." | ||
jetstream_api_call(NATS.Msg, connection, msg.reply_to; delays) | ||
end | ||
|
||
""" | ||
$(SIGNATURES) | ||
Mark message as undelivered, what avoid waiting for timeout before redelivery. | ||
""" | ||
function consumer_nak(connection::NATS.Connection, msg::NATS.Msg; delays = DEFAULT_API_CALL_DELAYS) | ||
isnothing(msg.reply_to) && error("No reply subject for msg $msg.") | ||
!startswith(msg.reply_to, "\$JS.ACK") && @warn "`nak` sent for message that doesn't need acknowledgement." | ||
jetstream_api_call(NATS.Msg, connection, msg.reply_to, "-NAK"; delays) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters