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/08/05 01:51:56 UTC

[GitHub] [pulsar-client-go] wolfstudy opened a new issue #40: When using the go client's producer to send messages, the cgo client's consumer cannot be consumed normally.

wolfstudy opened a new issue #40: When using the go client's producer to send messages, the cgo client's consumer cannot be consumed normally.
URL: https://github.com/apache/pulsar-client-go/issues/40
 
 
   #### Expected behavior
   
   When using the go client's producer to send messages, the cgo client's consumer can be consumed normally.
   
   #### Actual behavior
   
   go client producer:
   
   ```
   func main() {
       client, err := pulsar.NewClient(pulsar.ClientOptions{
           URL: "pulsar://localhost:6650",
       })
   
       if err != nil {
           log.Fatal(err)
       }
   
       defer client.Close()
   
       producer, err := client.CreateProducer(pulsar.ProducerOptions{
           Topic: "my-topic-1",
       })
       if err != nil {
           log.Fatal(err)
       }
   
       defer producer.Close()
   
       ctx := context.Background()
   
       for i := 0; i < 10; i++ {
           if err := producer.Send(ctx, &pulsar.ProducerMessage{
               Payload: []byte(fmt.Sprintf("hello-%d", i)),
           }); err != nil {
               log.Fatal(err)
           }
       }
   }
   ```
   
   cgo client consumer:
   
   ```
   func main() {
   	client, err := pulsar.NewClient(pulsar.ClientOptions{URL: "pulsar://localhost:6650"})
   	if err != nil {
   		log.Fatal(err)
   	}
   
   	defer client.Close()
   
   	consumer, err := client.Subscribe(pulsar.ConsumerOptions{
   		Topic:            "my-topic-1",
   		SubscriptionName: "my-subscription",
   		Type:             pulsar.Shared,
   	})
   	if err != nil {
   		log.Fatal(err)
   	}
   
   	defer consumer.Close()
   
   	for {
   		msg, err := consumer.Receive(context.Background())
   		if err != nil {
   			log.Fatal(err)
   		}
   
   		fmt.Printf("Received message  msgId: %s -- content: '%s'\n",
   			msg.ID(), string(msg.Payload()))
   
   		consumer.Ack(msg)
   	}
   }
   ```
   
   cgo client receive payload content is nil.
   
   ```
   Received message  msgId: (4,0,-1,0) -- content: ''
   Received message  msgId: (4,1,-1,0) -- content: ''
   Received message  msgId: (4,2,-1,0) -- content: ''
   Received message  msgId: (4,3,-1,0) -- content: ''
   Received message  msgId: (4,4,-1,0) -- content: ''
   Received message  msgId: (4,5,-1,0) -- content: ''
   Received message  msgId: (4,6,-1,0) -- content: ''
   Received message  msgId: (4,7,-1,0) -- content: ''
   Received message  msgId: (4,8,-1,0) -- content: ''
   Received message  msgId: (4,9,-1,0) -- content: ''
   ```
   #### Steps to reproduce
   
   How can we reproduce the issue
   
   #### System configuration
   **Pulsar version**: x.y
   

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