jerrypeng commented on a change in pull request #7237:
URL: https://github.com/apache/pulsar/pull/7237#discussion_r439939070



##########
File path: 
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionAssignmentTailer.java
##########
@@ -116,4 +147,51 @@ public void processAssignment(Message<byte[]> msg) {
             this.functionRuntimeManager.processAssignment(assignment);
         }
     }
+    
+    private Reader<byte[]> createReader() throws PulsarClientException {
+        MessageId startMessageId = lastMessageId == null ? MessageId.earliest 
: lastMessageId;
+        log.info("Assignment tailer will start reading from message id {}", 
startMessageId);
+
+        return readerBuilder
+                .subscriptionRolePrefix(workerConfig.getWorkerId() + 
"-function-assignment-tailer")
+                .readerName(workerConfig.getWorkerId() + 
"-function-assignment-tailer")
+                .topic(workerConfig.getFunctionAssignmentTopic())
+                .readCompacted(true)
+                .startMessageId(startMessageId)
+                .create();
+    }
+
+    private Thread getTailerThread() {
+        Thread t = new Thread(() -> {
+            while (isRunning) {
+                try {
+                    Message<byte[]> msg = reader.readNext(5, TimeUnit.SECONDS);
+                    if (msg == null) {
+                        if (exitOnEndOfTopic && !reader.hasMessageAvailable()) 
{
+                            break;
+                        }
+                    } else {
+                        processAssignment(msg);
+                        // keep track of the last message read
+                        lastMessageId = msg.getMessageId();
+                    }
+                } catch (Throwable th) {
+                    if (isRunning) {

Review comment:
       I don't think we need to since even if "exitOnEndOfTopic" is set 
,"isRunning" will still be set to true and any error will be bubbled up as 
expected 




----------------------------------------------------------------
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:
[email protected]


Reply via email to