You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/09/26 14:55:33 UTC
[GitHub] [pulsar-client-go] yangou opened a new issue #621: Ordering Key is always empty when consuming
yangou opened a new issue #621:
URL: https://github.com/apache/pulsar-client-go/issues/621
#### Expected behavior
After producing the message with ordering key, the consumer should be able to receive the message with ordering key.
#### Actual behavior
```golang
msg, err := consumer.Receive(context.Background())
fmt.Printf("Received message msgId: %#v -- content: '%s', topic: '%s', event time: %d, key: %s, order: %s, props: %v\n",
msg.ID(), string(msg.Payload()), msg.Topic(), msg.EventTime().Unix(), msg.Key(), msg.OrderingKey(), msg.Properties())
```
`msg.OrderingKey()` is returning empty string.
#### Steps to reproduce
Please use this code to reproduce
```golang
package main
import (
"context"
"fmt"
"log"
"os"
"time"
"github.com/apache/pulsar-client-go/pulsar"
// "github.com/sirupsen/logrus"
)
func main() {
// logrus.SetLevel(logrus.TraceLevel)
client, err := pulsar.NewClient(pulsar.ClientOptions{
URL: "pulsar://localhost:6650",
OperationTimeout: 30 * time.Second,
ConnectionTimeout: 30 * time.Second,
})
if err != nil {
log.Fatalf("Could not instantiate Pulsar client: %v", err)
}
defer client.Close()
if os.Args[1] == "produce" {
producer, err := client.CreateProducer(pulsar.ProducerOptions{
Topic: "123.json",
})
_, err = producer.Send(context.Background(), &pulsar.ProducerMessage{
Payload: []byte("hello"),
Key: "123xxxxx",
OrderingKey: "321xxxxx",
})
defer producer.Close()
if err != nil {
fmt.Println("Failed to publish message", err)
}
fmt.Println("Published message")
} else {
consumer, err := client.Subscribe(pulsar.ConsumerOptions{
Topic: "123.json",
SubscriptionName: "test",
Type: pulsar.Shared,
})
if err != nil {
log.Fatal(err)
}
defer consumer.Close()
for i := 0; i < 10; i++ {
msg, err := consumer.Receive(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Printf("Received message msgId: %#v -- content: '%s', topic: '%s', event time: %d, key: %s, order: %s, props: %v\n",
msg.ID(), string(msg.Payload()), msg.Topic(), msg.EventTime().Unix(), msg.Key(), msg.OrderingKey(), msg.Properties())
consumer.Ack(msg)
}
if err := consumer.Unsubscribe(); err != nil {
log.Fatal(err)
}
}
}
```
#### System configuration
**Pulsar version**: 2.7.1
Other clients are able to consume ordering key properly
--
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-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] leizhiyuan commented on issue #621: Ordering Key is always empty when consuming
Posted by GitBox <gi...@apache.org>.
leizhiyuan commented on issue #621:
URL: https://github.com/apache/pulsar-client-go/issues/621#issuecomment-1000252241
fix in https://github.com/apache/pulsar-client-go/pull/688
--
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-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] wolfstudy closed issue #621: Ordering Key is always empty when consuming
Posted by GitBox <gi...@apache.org>.
wolfstudy closed issue #621:
URL: https://github.com/apache/pulsar-client-go/issues/621
--
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-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org