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/07 06:45:12 UTC

[GitHub] [pulsar-client-go] wolfstudy opened a new issue #44: The logic of Flush error

wolfstudy opened a new issue #44: The logic of Flush error
URL: https://github.com/apache/pulsar-client-go/issues/44
 
 
   #### Expected behavior
   
   When I enable the batch function, the data in the batch should not be successfully consumed by the consumer when the size of the batch is not reached. Before the specified size of the batch is reached, only the operation that triggered Flush can flush the data in the batch.
   
   ```
   producer, err := client.CreateProducer(ProducerOptions{
   		Topic:                   topicName,
   		DisableBatching:         false,
   		BatchingMaxMessages:     uint(numOfMessages),
   		BatchingMaxPublishDelay: time.Second * 10,
   		BlockIfQueueFull:        true,
   	})
   ```
   
   #### Actual behavior
   
   When I enable the batch function, the data in the batch can be successfully consumed by the consumer when the size of the batch is not reached.
   
   #### Steps to reproduce
   
   ```
   func TestFlushInProducer(t *testing.T) {
   	client, err := NewClient(ClientOptions{
   		URL: serviceURL,
   	})
   	assert.NoError(t, err)
   
   	topicName := "test-flush-in-producer"
   	subName := "subscription-name"
   	numOfMessages := 10
   	ctx:=context.Background()
   
   	// set batch message number numOfMessages, and max delay 60s
   	producer, err := client.CreateProducer(ProducerOptions{
   		Topic:                   topicName,
   		DisableBatching:         false,
   		BatchingMaxMessages:     uint(numOfMessages),
   		BatchingMaxPublishDelay: time.Second * 10,
   		BlockIfQueueFull:        true,
   		Properties: map[string]string{
   			"producer-name": "test-producer-name",
   			"producer-id":   "test-producer-id",
   		},
   	})
   
   	consumer, err := client.Subscribe(ConsumerOptions{
   		Topic:            topicName,
   		SubscriptionName: subName,
   	})
   	assert.Nil(t, err)
   	defer consumer.Close()
   
   	prefix := "msg-batch-async"
   	msgCount := 0
   
   	for i := 0; i < numOfMessages/2; i++ {
   		messageContent := prefix + fmt.Sprintf("%d", i)
   		err := producer.Send(ctx, &ProducerMessage{
   			Payload: []byte(messageContent),
   		})
   		assert.Nil(t, err)
   	}
   
   	for i := 0; i < numOfMessages/2; i++ {
   		_, err := consumer.Receive(ctx)
   		assert.Nil(t, err)
   		msgCount++
   	}
   	assert.Equal(t, msgCount, numOfMessages/2)
   }
   ```
   
   #### 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