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 2019/12/18 13:08:27 UTC
[GitHub] [pulsar-client-go] wolfstudy opened a new issue #129: The consumer
can't Unsubscribe correctly in Failover sub mode
wolfstudy opened a new issue #129: The consumer can't Unsubscribe correctly in Failover sub mode
URL: https://github.com/apache/pulsar-client-go/issues/129
#### Steps to reproduce
run code as follows:
```
func TestSubFailOver(t *testing.T) {
client, err := NewClient(ClientOptions{
URL: lookupURL,
})
if err != nil {
t.Fatal(err)
}
topic := "test-failover-topic-4"
subName := "test-sub-4"
producer, err := client.CreateProducer(ProducerOptions{
Topic: topic,
})
assert.Nil(t, err)
for i := 0; i < 30; i++ {
err = producer.Send(context.Background(), &ProducerMessage{
Payload: []byte(fmt.Sprintf("message-%d", i)),
})
assert.Nil(t, err)
}
cfg := ConsumerOptions{
Topic: topic,
SubscriptionName: subName,
Type: Failover,
SubscriptionInitialPosition: SubscriptionPositionEarliest,
}
consumer1, err := client.Subscribe(cfg)
assert.Nil(t, err)
consumer2, err := client.Subscribe(cfg)
assert.Nil(t, err)
consumer3, err := client.Subscribe(cfg)
assert.Nil(t, err)
go func(consumer1 Consumer) {
for {
msg, err := consumer1.Receive(context.Background())
assert.Nil(t, err)
fmt.Printf("consumer-1 receive : %s\n", string(msg.Payload()))
}
}(consumer1)
go func(consumer2 Consumer) {
for {
msg, err := consumer2.Receive(context.Background())
assert.Nil(t, err)
fmt.Printf("consumer-2 receive : %s\n", string(msg.Payload()))
}
}(consumer2)
go func(consumer3 Consumer) {
for {
msg, err := consumer3.Receive(context.Background())
assert.Nil(t, err)
fmt.Printf("consumer-3 receive : %s\n", string(msg.Payload()))
}
}(consumer3)
time.Sleep(time.Second * 10)
consumer1.Unsubscribe()
consumer1.Close()
consumer2.Unsubscribe()
consumer2.Close()
consumer3.Unsubscribe()
consumer3.Close()
}
```

#### System configuration
**Pulsar version**: 2.5.0
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services