GitHub user raunakagrawal47 edited a comment on the discussion: Need max 
redelivery count at message level.

My consumer looks like this right now:

> pulsarClient.newConsumer()
                    .topic("my-topic")
                    .subscriptionType(SubscriptionType.Shared)
                    .subscriptionName("my-subscription")
                    .receiverQueueSize(10)
                    .enableRetry(true)
                    .subscribe()

                    
 I have not set any `deadLetterPolicy ` and `ackTimeout` since I wanted to send 
messages to DLQ using my own producer after max retries are exhausted. Max 
retries are also defined at the message level.
 
 Also, I have some logic written for sending the message to DLQ. Since I am 
sending to DLQ based on expire duration set for each message, I have not put 
`ackTimeout` at the consumer level.
 
 

>  if (hours > retryExpiryAfterDuration) {   // Don't retry after expiry 
> duration set. Hour is calculated from the time the message first arrived 
> difference from the current time.
                        // send to DLQ .... retries are exhausted.
                        System.out.println("Sending to DLQ after max number of 
retries");
                        MessageId messageId = 
pulsarProducerDLQ.send(String.valueOf(msg));
                        if (messageId != null) {
                            consumer.acknowledge(msg); // acknowledge here to 
remove from the main queue.
                        }
                        return;
                    }    

   
   
   Since DLQ is just another topic, I was able to send a message to the DLQ 
topic using `pulsarProducerDLQ`. Could you please let me know if this is the 
right way to go about it ?
                      

GitHub link: 
https://github.com/apache/pulsar/discussions/17626#discussioncomment-3686143

----
This is an automatically sent email for dev@pulsar.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@pulsar.apache.org

Reply via email to