crossoverJie commented on code in PR #999:
URL: https://github.com/apache/pulsar-client-go/pull/999#discussion_r1241080818
##########
pulsar/producer_test.go:
##########
@@ -560,6 +560,38 @@ func TestMessageRouter(t *testing.T) {
assert.NotNil(t, msg)
assert.Equal(t, string(msg.Payload()), "hello")
}
+func TestMessageSingleRouter(t *testing.T) {
+ // Create topic with 5 partitions
+ topicAdminURL :=
"admin/v2/persistent/public/default/my-single-partitioned-topic/partitions"
+ err := httpPut(topicAdminURL, 5)
+ defer httpDelete(topicAdminURL)
+ if err != nil {
+ t.Fatal(err)
+ }
+ client, err := NewClient(ClientOptions{
+ URL: serviceURL,
+ })
+
+ assert.Nil(t, err)
+ defer client.Close()
+
+ producer, err := client.CreateProducer(ProducerOptions{
+ Topic: "my-single-partitioned-topic",
+ MessageRouter: NewSinglePartitionRouter(),
+ })
+
+ assert.Nil(t, err)
+ defer producer.Close()
+
+ ctx := context.Background()
+
+ ID, err := producer.Send(ctx, &ProducerMessage{
+ Payload: []byte("hello"),
+ })
+ assert.Nil(t, err)
+ assert.NotNil(t, ID)
+
Review Comment:
Need to expose a function `GetSinglePartition() int` that returns the
current partition, then only consume messages from that single partition.
Any other suggestions?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]