Skip to content

Commit

Permalink
add explicit ack/nak for nats jetstream
Browse files Browse the repository at this point in the history
Signed-off-by: stephen-totty-hpe <stephen.totty@hpe.com>
  • Loading branch information
stephen-totty-hpe committed Jul 9, 2024
1 parent 8efefb0 commit c000d07
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions protocol/nats_jetstream/v2/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ func (m *Message) ReadBinary(ctx context.Context, encoder binding.BinaryWriter)

// Finish *must* be called when message from a Receiver can be forgotten by the receiver.
func (m *Message) Finish(err error) error {
// Ignore error if message has already been Ack/Nak.
// Ack and Nak first checks to see if the message has been acknowleged
// and immediately returns an error without applying any logic to the message on the server.
// A message will auto acknowledge unless manual ack is set or policy is set to AckNonePolicy
// see: ManualAck() subscription option
// see: ConsumerConfig.AckPolicy
if err != nil {
_ = m.Msg.Nak()
return nil
}
_ = m.Msg.Ack()
return nil
}

Expand Down

0 comments on commit c000d07

Please sign in to comment.