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 2022/12/07 11:40:30 UTC

[GitHub] [pulsar] crossoverJie opened a new issue, #18799: PIP-227: New API for closing the consumer after waiting for the job to complete

crossoverJie opened a new issue, #18799:
URL: https://github.com/apache/pulsar/issues/18799

   ### Motivation
   
   Wait for the consumer's job to finish before closing the consumer, and fix #8308 
   
   ### Goal
   
   In some scenarios, we need the consumer to finish executing the task before closing it, otherwise, the message will be consumed again when the consumer restarts.
   
   ### API Changes
   
   `ConsumerBuilder` will add a new parameter.
   
   ```java
   Consumer<String> consumer = pulsarClient.newConsumer(Schema.STRING)
           .topics(listTopic)
           .subscriptionName(subscriptionName)
           .subscriptionType(SubscriptionType.Shared)
           .closeWaitForJob(CloseWaitForJobPolicy.builder()
                   .closeWaitForJob(true)
                   .timeout(5, TimeUnit.SECONDS)
                   .build())
           .subscribe();
   ```
   
   ### Implementation
   
   New wait notification mechanism when closing consumer.
   
   The main steps are as follows:
   - Record the number of messages received.
   	- Related functions: `receive()/batchReceive()` etc.
   - When processing a message, the number of messages is subtracted by one, and a notification is sent when the number of messages equals 0.
   	- Related functions: `acknowledge()/negativeAcknowledge()`
   - Blocks the thread when the consumer is closed until it is woken up.
   	- Related function: `close()`.
   
    The prerequisite here is that the user uses this API.
   
   ### Alternatives
   
   _No response_
   
   ### Anything else?
   
   PR: https://github.com/apache/pulsar/pull/18795


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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] github-actions[bot] commented on issue #18799: PIP-227: New API for closing the consumer after waiting for the job to complete

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #18799:
URL: https://github.com/apache/pulsar/issues/18799#issuecomment-1374346579

   The issue had no activity for 30 days, mark with Stale label.


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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] crossoverJie closed issue #18799: PIP-227: New API for closing the consumer after waiting for the job to complete

Posted by "crossoverJie (via GitHub)" <gi...@apache.org>.
crossoverJie closed issue #18799: PIP-227: New API for closing the consumer after waiting for the job to complete
URL: https://github.com/apache/pulsar/issues/18799


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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org