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/04/25 14:47:21 UTC

[GitHub] [pulsar-client-go] wolfstudy commented on issue #233: Reader cannot read first message produced to new topic

wolfstudy commented on issue #233:
URL: https://github.com/apache/pulsar-client-go/issues/233#issuecomment-619390303


   @frankjkelly Thanks feedback. 
   
   Maybe we can try the following methods:
   
   ```
    consumer, err := writerClient.Subscribe(pulsar.ConsumerOptions{
   		Topic:                       signalId,
   		SubscriptionName:            "Consumah",
   		SubscriptionInitialPosition: pulsar.SubscriptionPositionEarliest,
   		Type:                        pulsar.Exclusive,
   	})
   	if err != nil {
   		log.Fatal(err)
   	}
   	defer consumer.Close()
   ```
   
   Output:
   
   ```
   Received message msgId: &pulsar.messageID{ledgerID:10, entryID:1, batchIdx:0, partitionIdx:0, tracker:(*pulsar.ackTracker)(nil), consumer:(*pulsar.partitionConsumer)(0xc001074680)} -- content: 'my message'
   ```
   
   By default, the consumer of pulsar will start receiving messages from the `latest` position. If you want to receive messages sent before, you can set the Consumer's SubscriptionInitialPosition option to `SubscriptionPositionEarliest`.


----------------------------------------------------------------
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