storm-5 commented on issue #12832:
URL: https://github.com/apache/pulsar/issues/12832#issuecomment-972675070


   > could you provide the go code to test this issue?
   
   here is. I have wipe the sensitive info.
   
   ```go
   
   package main
   
   import (
        "context"
        "fmt"
        "time"
   
        "github.com/apache/pulsar-client-go/pulsar"
   )
   
   func main() {
        url := ""
        token := ""
        topic := ""
        subscName := ""
   
        client, _ := pulsar.NewClient(pulsar.ClientOptions{
                URL:               url,
                Authentication:    pulsar.NewAuthenticationToken(token),
                OperationTimeout:  30 * time.Second,
                ConnectionTimeout: 30 * time.Second,
        })
   
        producer, _ := client.CreateProducer(pulsar.ProducerOptions{
                Topic: topic,
        })
        snmid, _ := producer.Send(context.Background(), &pulsar.ProducerMessage{
                Payload: []byte("hello"),
        })
        fmt.Printf("%x", snmid.Serialize())
   
        consumer, err := client.Subscribe(pulsar.ConsumerOptions{
                Topic:            topic,
                SubscriptionName: subscName,
                Type:             pulsar.Shared,
                RetryEnable:      true,
                DLQ: &pulsar.DLQPolicy{
                        MaxDeliveries:    1,
                        RetryLetterTopic: topic + "-RETRY",
                        DeadLetterTopic:  topic + "-DLQ",
                },
        })
        fmt.Printf("%s", err)
        ctx, cancel := context.WithTimeout(context.Background(), 
10000*time.Millisecond)
        defer cancel()
        for {
                msg, _ := consumer.Receive(ctx)
                midOri := msg.ID()
                midBytes := midOri.Serialize()
                midNew, _ := pulsar.DeserializeMessageID(midBytes)
                consumer.AckID(midNew)
                // consumer.AckID(midOri)
                // consumer.Ack(msg)
                fmt.Printf("%s, ", msg.Payload())
        }
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to