You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ba...@apache.org on 2023/03/15 07:27:03 UTC

[pulsar-client-go] branch master updated: fix:when send error, nack the message (#592)

This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git


The following commit(s) were added to refs/heads/master by this push:
     new 257a9c8  fix:when send error, nack the message (#592)
257a9c8 is described below

commit 257a9c84cc4c255e4c8ceb5a77f6abcbd927ff09
Author: Lei Zhiyuan <le...@gmail.com>
AuthorDate: Wed Mar 15 15:26:56 2023 +0800

    fix:when send error, nack the message (#592)
---
 pulsar/dlq_router.go | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/pulsar/dlq_router.go b/pulsar/dlq_router.go
index 5ecd8f8..6d30003 100644
--- a/pulsar/dlq_router.go
+++ b/pulsar/dlq_router.go
@@ -109,13 +109,17 @@ func (r *dlqRouter) run() {
 				Properties:          properties,
 				EventTime:           msg.EventTime(),
 				ReplicationClusters: msg.replicationClusters,
-			}, func(MessageID, *ProducerMessage, error) {
-				r.log.WithField("msgID", msgID).Debug("Sent message to DLQ")
-
-				// The Producer ack might be coming from the connection go-routine that
-				// is also used by the consumer. In that case we would get a dead-lock
-				// if we'd try to ack.
-				go cm.Consumer.AckID(msgID)
+			}, func(messageID MessageID, producerMessage *ProducerMessage, err error) {
+				if err == nil {
+					r.log.WithField("msgID", msgID).Debug("Succeed to send message to DLQ")
+					// The Producer ack might be coming from the connection go-routine that
+					// is also used by the consumer. In that case we would get a dead-lock
+					// if we'd try to ack.
+					go cm.Consumer.AckID(msgID)
+				} else {
+					r.log.WithError(err).WithField("msgID", msgID).Debug("Failed to send message to DLQ")
+					go cm.Consumer.Nack(cm)
+				}
 			})
 
 		case <-r.closeCh: