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 2020/05/08 01:28:19 UTC
[GitHub] [pulsar-client-go] phemmer opened a new issue #241: HasNext returns false when message is available
phemmer opened a new issue #241:
URL: https://github.com/apache/pulsar-client-go/issues/241
#### Expected behavior
`Reader.HasNext()` should return `true` when messages are available.
#### Actual behavior
`Reader.HasNext()` returns `false` when messages are available.
#### Steps to reproduce
```go
package main
import (
"context"
"fmt"
"os"
"github.com/apache/pulsar-client-go/pulsar"
)
func main() {
if err := Main(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %s\n", err)
os.Exit(1)
}
os.Exit(0)
}
func Main() error {
client, err := pulsar.NewClient(pulsar.ClientOptions{
URL: "pulsar://localhost:6650",
})
if err != nil { return err }
producer, err := client.CreateProducer(pulsar.ProducerOptions{
Topic: "persistent://public/test/test",
})
if err != nil { return err }
id, err := producer.Send(context.Background(), &pulsar.ProducerMessage{Payload: []byte("test")})
if err != nil { return err }
consumer, err := client.CreateReader(pulsar.ReaderOptions{
Topic: "persistent://public/test/test",
StartMessageID: id,
StartMessageIDInclusive: true,
})
hasnext := consumer.HasNext()
if err != nil { return err }
fmt.Printf("HasNext: %v\n", hasnext)
next, err := consumer.Next(context.Background())
if err != nil { return err }
fmt.Printf("Next: %+v\n", next)
return nil
}
```
```
INFO[0000] Connecting to broker remote_addr="pulsar://localhost:6650"
INFO[0000] TCP connection established local_addr="127.0.0.1:33626" remote_addr="pulsar://localhost:6650"
INFO[0000] Connection is ready local_addr="127.0.0.1:33626" remote_addr="pulsar://localhost:6650"
INFO[0000] Created producer cnx="127.0.0.1:33626 -> 127.0.0.1:6650" producer_name=standalone-0-130 topic="persistent://public/test/test"
INFO[0000] Connected consumer name= subscription=reader-knfbf topic="persistent://public/test/test"
INFO[0000] Created consumer name= subscription=reader-knfbf topic="persistent://public/test/test"
HasNext: false
Next: &{publishTime:{wall:195000000 ext:63724497913 loc:0xc19de0} eventTime:{wall:128448384 ext:55340232221 loc:0xc19de0} key: payLoad:[116 101 115 116] msgID:0xc000172000 properties:map[] topic:persistent://public/test/test replicationClusters:[] redeliveryCount:0}
```
#### System configuration
**Pulsar version**: 2.5.1
----------------------------------------------------------------
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
[GitHub] [pulsar-client-go] wolfstudy commented on issue #241: HasNext returns false when message is available
Posted by GitBox <gi...@apache.org>.
wolfstudy commented on issue #241:
URL: https://github.com/apache/pulsar-client-go/issues/241#issuecomment-678913764
The issue will be fixed in #329
----------------------------------------------------------------
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
[GitHub] [pulsar-client-go] wolfstudy closed issue #241: HasNext returns false when message is available
Posted by GitBox <gi...@apache.org>.
wolfstudy closed issue #241:
URL: https://github.com/apache/pulsar-client-go/issues/241
----------------------------------------------------------------
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
[GitHub] [pulsar-client-go] wolfstudy commented on issue #241: HasNext returns false when message is available
Posted by GitBox <gi...@apache.org>.
wolfstudy commented on issue #241:
URL: https://github.com/apache/pulsar-client-go/issues/241#issuecomment-629976251
You can try to use the following code example:
```
consumer, err := client.CreateReader(pulsar.ReaderOptions{
Topic: "persistent://public/default/test",
StartMessageID: pulsar.EarliestMessageID(),
StartMessageIDInclusive: true,
})
```
More use reference to [here](https://github.com/apache/pulsar-client-go/blob/master/pulsar/reader_test.go#L315-L364)
----------------------------------------------------------------
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