You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "fabian4 (via GitHub)" <gi...@apache.org> on 2023/09/19 08:35:58 UTC

[PR] [ISSUE #4450] Add retry strategy for sourceWorker. (eventmesh)

fabian4 opened a new pull request, #4451:
URL: https://github.com/apache/eventmesh/pull/4451

   <!--
   ### Contribution Checklist
   
     - Name the pull request in the form "[ISSUE #XXXX] Title of the pull request", 
       where *XXXX* should be replaced by the actual issue number.
       Skip *[ISSUE #XXXX]* if there is no associated github issue for this pull request.
   
     - Fill out the template below to describe the changes contributed by the pull request. 
       That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue. 
       Please do not mix up code from multiple issues.
     
     - Each commit in the pull request should have a meaningful commit message.
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, 
       leaving only the filled out template below.
   
   (The sections below can be removed for hotfixes of typos)
   -->
   
   <!--
   (If this PR fixes a GitHub issue, please add `Fixes #<XXX>` or `Closes #<XXX>`.)
   -->
   
   Fixes #4450.
   
   ### Motivation
   
   *Explain the content here.*
   *Explain why you want to make the changes and what problem you're trying to solve.*
   
   
   
   ### Modifications
   
   Add retry strategy for sourceWorker.
   
   
   
   ### Documentation
   
   - Does this pull request introduce a new feature? (yes / no)
   - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
   - If a feature is not applicable for documentation, explain why?
   - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


Re: [PR] [ISSUE #4450] Add retry strategy for sourceWorker. (eventmesh)

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #4451:
URL: https://github.com/apache/eventmesh/pull/4451#issuecomment-1725206902

   ## [Codecov](https://app.codecov.io/gh/apache/eventmesh/pull/4451?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#4451](https://app.codecov.io/gh/apache/eventmesh/pull/4451?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (95c9f70) into [master](https://app.codecov.io/gh/apache/eventmesh/commit/ff663e2fed0965f054a04c632dfcb768189fe3e3?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (ff663e2) will **increase** coverage by `0.00%`.
   > The diff coverage is `n/a`.
   
   > :exclamation: Current head 95c9f70 differs from pull request most recent head 49076b3. Consider uploading reports for the commit 49076b3 to get more accurate results
   
   ```diff
   @@            Coverage Diff            @@
   ##             master    #4451   +/-   ##
   =========================================
     Coverage     15.94%   15.94%           
     Complexity     1475     1475           
   =========================================
     Files           689      689           
     Lines         27527    27523    -4     
     Branches       2568     2552   -16     
   =========================================
   + Hits           4388     4389    +1     
   + Misses        22689    22687    -2     
   + Partials        450      447    -3     
   ```
   
   
   [see 14 files with indirect coverage changes](https://app.codecov.io/gh/apache/eventmesh/pull/4451/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
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: issues-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4450] Add retry strategy for sourceWorker. (eventmesh)

Posted by "fabian4 (via GitHub)" <gi...@apache.org>.
fabian4 commented on code in PR #4451:
URL: https://github.com/apache/eventmesh/pull/4451#discussion_r1330172448


##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -177,19 +179,30 @@ public void startPollAndSend() {
             // todo: convert connectRecord to cloudevent
             CloudEvent event = convertRecordToEvent(connectRecord);
             Optional<RecordOffsetManagement.SubmittedPosition> submittedRecordPosition = prepareToUpdateRecordOffset(connectRecord);
-            Package sendResult = eventMeshTCPClient.publish(event, 3000);
 
-            if (sendResult.getHeader().getCode() == 0) {
-                // publish success
-                // commit record
-                this.source.commit(connectRecord);
-                submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
-            } else {
-                // todo: retry or other strategy
-                log.error("{} failed to send record to {}, failed record {}", this, event.getSubject(), connectRecord);
+            int retryTimes = 0;
+            // retry until MAX_RETRY_TIMES is reached
+            while (retryTimes < MAX_RETRY_TIMES) {
+                try {
+                    Package sendResult = eventMeshTCPClient.publish(event, 3000);
+                    if (sendResult.getHeader().getCode() == 0) {
+                        // publish success
+                        // commit record
+                        this.source.commit(connectRecord);
+                        submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
+                        break;
+                    }
+                    retryTimes++;
+                    log.warn("{} failed to send record to {}, retry times = {}, failed record {}",
+                            this, event.getSubject(), retryTimes, connectRecord);
+                } catch (Throwable t) {
+                    retryTimes++;
+                    log.error("{} failed to send record to {}, retry times = {}, failed record {}, throw {}",
+                            this, event.getSubject(), retryTimes, connectRecord, t.getMessage());
+                }
             }
 
-            offsetManagement.awaitAllMessages(5000, TimeUnit.MILLISECONDS);
+            offsetManagement.awaitAllMessages(15000, TimeUnit.MILLISECONDS);

Review Comment:
   My mistake !!! 🫨🫨🫨
   Thanks for the correction



##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -177,19 +179,30 @@ public void startPollAndSend() {
             // todo: convert connectRecord to cloudevent
             CloudEvent event = convertRecordToEvent(connectRecord);
             Optional<RecordOffsetManagement.SubmittedPosition> submittedRecordPosition = prepareToUpdateRecordOffset(connectRecord);
-            Package sendResult = eventMeshTCPClient.publish(event, 3000);
 
-            if (sendResult.getHeader().getCode() == 0) {
-                // publish success
-                // commit record
-                this.source.commit(connectRecord);
-                submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
-            } else {
-                // todo: retry or other strategy
-                log.error("{} failed to send record to {}, failed record {}", this, event.getSubject(), connectRecord);
+            int retryTimes = 0;
+            // retry until MAX_RETRY_TIMES is reached
+            while (retryTimes < MAX_RETRY_TIMES) {
+                try {
+                    Package sendResult = eventMeshTCPClient.publish(event, 3000);
+                    if (sendResult.getHeader().getCode() == 0) {
+                        // publish success
+                        // commit record
+                        this.source.commit(connectRecord);
+                        submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
+                        break;
+                    }
+                    retryTimes++;
+                    log.warn("{} failed to send record to {}, retry times = {}, failed record {}",
+                            this, event.getSubject(), retryTimes, connectRecord);
+                } catch (Throwable t) {
+                    retryTimes++;
+                    log.error("{} failed to send record to {}, retry times = {}, failed record {}, throw {}",
+                            this, event.getSubject(), retryTimes, connectRecord, t.getMessage());
+                }
             }
 
-            offsetManagement.awaitAllMessages(5000, TimeUnit.MILLISECONDS);
+            offsetManagement.awaitAllMessages(15000, TimeUnit.MILLISECONDS);

Review Comment:
   My mistake !!! 🫨🫨🫨
   Thanks for the correction



-- 
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: issues-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4450] Add retry strategy for sourceWorker. (eventmesh)

Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4451:
URL: https://github.com/apache/eventmesh/pull/4451#discussion_r1329844679


##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -177,19 +179,30 @@ public void startPollAndSend() {
             // todo: convert connectRecord to cloudevent
             CloudEvent event = convertRecordToEvent(connectRecord);
             Optional<RecordOffsetManagement.SubmittedPosition> submittedRecordPosition = prepareToUpdateRecordOffset(connectRecord);
-            Package sendResult = eventMeshTCPClient.publish(event, 3000);
 
-            if (sendResult.getHeader().getCode() == 0) {
-                // publish success
-                // commit record
-                this.source.commit(connectRecord);
-                submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
-            } else {
-                // todo: retry or other strategy
-                log.error("{} failed to send record to {}, failed record {}", this, event.getSubject(), connectRecord);
+            int retryTimes = 0;
+            // retry until MAX_RETRY_TIMES is reached
+            while (retryTimes < MAX_RETRY_TIMES) {
+                try {
+                    Package sendResult = eventMeshTCPClient.publish(event, 3000);
+                    if (sendResult.getHeader().getCode() == 0) {
+                        // publish success
+                        // commit record
+                        this.source.commit(connectRecord);
+                        submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
+                        break;
+                    }
+                    retryTimes++;
+                    log.warn("{} failed to send record to {}, retry times = {}, failed record {}",
+                            this, event.getSubject(), retryTimes, connectRecord);
+                } catch (Throwable t) {
+                    retryTimes++;
+                    log.error("{} failed to send record to {}, retry times = {}, failed record {}, throw {}",
+                            this, event.getSubject(), retryTimes, connectRecord, t.getMessage());
+                }
             }
 
-            offsetManagement.awaitAllMessages(5000, TimeUnit.MILLISECONDS);
+            offsetManagement.awaitAllMessages(15000, TimeUnit.MILLISECONDS);

Review Comment:
   A reduced timeout value that covers 90% of the timeout cases would be preferable, instead of waiting for a long time.



-- 
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: issues-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4450] Add retry strategy for sourceWorker. (eventmesh)

Posted by "mxsm (via GitHub)" <gi...@apache.org>.
mxsm merged PR #4451:
URL: https://github.com/apache/eventmesh/pull/4451


-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


Re: [PR] [ISSUE #4450] Add retry strategy for sourceWorker. (eventmesh)

Posted by "fabian4 (via GitHub)" <gi...@apache.org>.
fabian4 commented on code in PR #4451:
URL: https://github.com/apache/eventmesh/pull/4451#discussion_r1329794671


##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -177,19 +179,30 @@ public void startPollAndSend() {
             // todo: convert connectRecord to cloudevent
             CloudEvent event = convertRecordToEvent(connectRecord);
             Optional<RecordOffsetManagement.SubmittedPosition> submittedRecordPosition = prepareToUpdateRecordOffset(connectRecord);
-            Package sendResult = eventMeshTCPClient.publish(event, 3000);
 
-            if (sendResult.getHeader().getCode() == 0) {
-                // publish success
-                // commit record
-                this.source.commit(connectRecord);
-                submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
-            } else {
-                // todo: retry or other strategy
-                log.error("{} failed to send record to {}, failed record {}", this, event.getSubject(), connectRecord);
+            int retryTimes = 0;
+            // retry until MAX_RETRY_TIMES is reached
+            while (retryTimes < MAX_RETRY_TIMES) {
+                try {
+                    Package sendResult = eventMeshTCPClient.publish(event, 3000);
+                    if (sendResult.getHeader().getCode() == 0) {
+                        // publish success
+                        // commit record
+                        this.source.commit(connectRecord);
+                        submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
+                        break;
+                    }
+                    retryTimes++;
+                    log.warn("{} failed to send record to {}, retry times = {}, failed record {}",
+                            this, event.getSubject(), retryTimes, connectRecord);
+                } catch (Throwable t) {
+                    retryTimes++;
+                    log.error("{} failed to send record to {}, retry times = {}, failed record {}, throw {}",
+                            this, event.getSubject(), retryTimes, connectRecord, t.getMessage());
+                }
             }
 
-            offsetManagement.awaitAllMessages(5000, TimeUnit.MILLISECONDS);
+            offsetManagement.awaitAllMessages(15000, TimeUnit.MILLISECONDS);

Review Comment:
   I tripled it for the worst situation.  3000 * 3 -> 5000 * 3 (Or just make sure it is bigger than 3000 * 3 
   
   



-- 
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: issues-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4450] Add retry strategy for sourceWorker. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4451:
URL: https://github.com/apache/eventmesh/pull/4451#discussion_r1329863810


##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -177,19 +179,30 @@ public void startPollAndSend() {
             // todo: convert connectRecord to cloudevent
             CloudEvent event = convertRecordToEvent(connectRecord);
             Optional<RecordOffsetManagement.SubmittedPosition> submittedRecordPosition = prepareToUpdateRecordOffset(connectRecord);
-            Package sendResult = eventMeshTCPClient.publish(event, 3000);
 
-            if (sendResult.getHeader().getCode() == 0) {
-                // publish success
-                // commit record
-                this.source.commit(connectRecord);
-                submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
-            } else {
-                // todo: retry or other strategy
-                log.error("{} failed to send record to {}, failed record {}", this, event.getSubject(), connectRecord);
+            int retryTimes = 0;
+            // retry until MAX_RETRY_TIMES is reached
+            while (retryTimes < MAX_RETRY_TIMES) {
+                try {
+                    Package sendResult = eventMeshTCPClient.publish(event, 3000);
+                    if (sendResult.getHeader().getCode() == 0) {
+                        // publish success
+                        // commit record
+                        this.source.commit(connectRecord);
+                        submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
+                        break;
+                    }
+                    retryTimes++;
+                    log.warn("{} failed to send record to {}, retry times = {}, failed record {}",
+                            this, event.getSubject(), retryTimes, connectRecord);
+                } catch (Throwable t) {
+                    retryTimes++;
+                    log.error("{} failed to send record to {}, retry times = {}, failed record {}, throw {}",
+                            this, event.getSubject(), retryTimes, connectRecord, t.getMessage());
+                }
             }
 
-            offsetManagement.awaitAllMessages(5000, TimeUnit.MILLISECONDS);
+            offsetManagement.awaitAllMessages(15000, TimeUnit.MILLISECONDS);

Review Comment:
   > I tripled it for the worst situation. 3000 * 3 -> 5000 * 3 (Or just make sure it is bigger than 3000 * 3
   
   Why triple? Is '* 3' related to the number of retries?



-- 
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: issues-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4450] Add retry strategy for sourceWorker. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4451:
URL: https://github.com/apache/eventmesh/pull/4451#discussion_r1330153537


##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -177,19 +179,30 @@ public void startPollAndSend() {
             // todo: convert connectRecord to cloudevent
             CloudEvent event = convertRecordToEvent(connectRecord);
             Optional<RecordOffsetManagement.SubmittedPosition> submittedRecordPosition = prepareToUpdateRecordOffset(connectRecord);
-            Package sendResult = eventMeshTCPClient.publish(event, 3000);
 
-            if (sendResult.getHeader().getCode() == 0) {
-                // publish success
-                // commit record
-                this.source.commit(connectRecord);
-                submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
-            } else {
-                // todo: retry or other strategy
-                log.error("{} failed to send record to {}, failed record {}", this, event.getSubject(), connectRecord);
+            int retryTimes = 0;
+            // retry until MAX_RETRY_TIMES is reached
+            while (retryTimes < MAX_RETRY_TIMES) {
+                try {
+                    Package sendResult = eventMeshTCPClient.publish(event, 3000);
+                    if (sendResult.getHeader().getCode() == 0) {
+                        // publish success
+                        // commit record
+                        this.source.commit(connectRecord);
+                        submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
+                        break;
+                    }
+                    retryTimes++;
+                    log.warn("{} failed to send record to {}, retry times = {}, failed record {}",
+                            this, event.getSubject(), retryTimes, connectRecord);
+                } catch (Throwable t) {
+                    retryTimes++;
+                    log.error("{} failed to send record to {}, retry times = {}, failed record {}, throw {}",
+                            this, event.getSubject(), retryTimes, connectRecord, t.getMessage());
+                }
             }
 
-            offsetManagement.awaitAllMessages(5000, TimeUnit.MILLISECONDS);
+            offsetManagement.awaitAllMessages(15000, TimeUnit.MILLISECONDS);

Review Comment:
   Do you mean that `while () {}` and `offsetManagement.awaitAllMessages ()` are executed asynchronously?



-- 
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: issues-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4450] Add retry strategy for sourceWorker. (eventmesh)

Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4451:
URL: https://github.com/apache/eventmesh/pull/4451#discussion_r1329825571


##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -177,19 +179,30 @@ public void startPollAndSend() {
             // todo: convert connectRecord to cloudevent
             CloudEvent event = convertRecordToEvent(connectRecord);
             Optional<RecordOffsetManagement.SubmittedPosition> submittedRecordPosition = prepareToUpdateRecordOffset(connectRecord);
-            Package sendResult = eventMeshTCPClient.publish(event, 3000);
 
-            if (sendResult.getHeader().getCode() == 0) {
-                // publish success
-                // commit record
-                this.source.commit(connectRecord);
-                submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
-            } else {
-                // todo: retry or other strategy
-                log.error("{} failed to send record to {}, failed record {}", this, event.getSubject(), connectRecord);
+            int retryTimes = 0;
+            // retry until MAX_RETRY_TIMES is reached
+            while (retryTimes < MAX_RETRY_TIMES) {
+                try {
+                    Package sendResult = eventMeshTCPClient.publish(event, 3000);
+                    if (sendResult.getHeader().getCode() == 0) {
+                        // publish success
+                        // commit record
+                        this.source.commit(connectRecord);
+                        submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
+                        break;
+                    }
+                    retryTimes++;
+                    log.warn("{} failed to send record to {}, retry times = {}, failed record {}",
+                            this, event.getSubject(), retryTimes, connectRecord);
+                } catch (Throwable t) {
+                    retryTimes++;
+                    log.error("{} failed to send record to {}, retry times = {}, failed record {}, throw {}",
+                            this, event.getSubject(), retryTimes, connectRecord, t.getMessage());
+                }
             }
 
-            offsetManagement.awaitAllMessages(5000, TimeUnit.MILLISECONDS);
+            offsetManagement.awaitAllMessages(15000, TimeUnit.MILLISECONDS);

Review Comment:
   Reducing the retry timeout and increasing the number of retries will be more effective.



-- 
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: issues-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4450] Add retry strategy for sourceWorker. (eventmesh)

Posted by "fabian4 (via GitHub)" <gi...@apache.org>.
fabian4 commented on code in PR #4451:
URL: https://github.com/apache/eventmesh/pull/4451#discussion_r1330075350


##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -177,19 +179,30 @@ public void startPollAndSend() {
             // todo: convert connectRecord to cloudevent
             CloudEvent event = convertRecordToEvent(connectRecord);
             Optional<RecordOffsetManagement.SubmittedPosition> submittedRecordPosition = prepareToUpdateRecordOffset(connectRecord);
-            Package sendResult = eventMeshTCPClient.publish(event, 3000);
 
-            if (sendResult.getHeader().getCode() == 0) {
-                // publish success
-                // commit record
-                this.source.commit(connectRecord);
-                submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
-            } else {
-                // todo: retry or other strategy
-                log.error("{} failed to send record to {}, failed record {}", this, event.getSubject(), connectRecord);
+            int retryTimes = 0;
+            // retry until MAX_RETRY_TIMES is reached
+            while (retryTimes < MAX_RETRY_TIMES) {
+                try {
+                    Package sendResult = eventMeshTCPClient.publish(event, 3000);
+                    if (sendResult.getHeader().getCode() == 0) {
+                        // publish success
+                        // commit record
+                        this.source.commit(connectRecord);
+                        submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
+                        break;
+                    }
+                    retryTimes++;
+                    log.warn("{} failed to send record to {}, retry times = {}, failed record {}",
+                            this, event.getSubject(), retryTimes, connectRecord);
+                } catch (Throwable t) {
+                    retryTimes++;
+                    log.error("{} failed to send record to {}, retry times = {}, failed record {}, throw {}",
+                            this, event.getSubject(), retryTimes, connectRecord, t.getMessage());
+                }
             }
 
-            offsetManagement.awaitAllMessages(5000, TimeUnit.MILLISECONDS);
+            offsetManagement.awaitAllMessages(15000, TimeUnit.MILLISECONDS);

Review Comment:
   > Why triple? Is '* 3' related to the number of retries?
   
   Considering it would succeed on the last try



-- 
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: issues-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4450] Add retry strategy for sourceWorker. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4451:
URL: https://github.com/apache/eventmesh/pull/4451#discussion_r1329783401


##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -177,19 +179,30 @@ public void startPollAndSend() {
             // todo: convert connectRecord to cloudevent
             CloudEvent event = convertRecordToEvent(connectRecord);
             Optional<RecordOffsetManagement.SubmittedPosition> submittedRecordPosition = prepareToUpdateRecordOffset(connectRecord);
-            Package sendResult = eventMeshTCPClient.publish(event, 3000);
 
-            if (sendResult.getHeader().getCode() == 0) {
-                // publish success
-                // commit record
-                this.source.commit(connectRecord);
-                submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
-            } else {
-                // todo: retry or other strategy
-                log.error("{} failed to send record to {}, failed record {}", this, event.getSubject(), connectRecord);
+            int retryTimes = 0;
+            // retry until MAX_RETRY_TIMES is reached
+            while (retryTimes < MAX_RETRY_TIMES) {
+                try {
+                    Package sendResult = eventMeshTCPClient.publish(event, 3000);
+                    if (sendResult.getHeader().getCode() == 0) {
+                        // publish success
+                        // commit record
+                        this.source.commit(connectRecord);
+                        submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
+                        break;
+                    }
+                    retryTimes++;
+                    log.warn("{} failed to send record to {}, retry times = {}, failed record {}",
+                            this, event.getSubject(), retryTimes, connectRecord);
+                } catch (Throwable t) {
+                    retryTimes++;
+                    log.error("{} failed to send record to {}, retry times = {}, failed record {}, throw {}",
+                            this, event.getSubject(), retryTimes, connectRecord, t.getMessage());
+                }
             }
 
-            offsetManagement.awaitAllMessages(5000, TimeUnit.MILLISECONDS);
+            offsetManagement.awaitAllMessages(15000, TimeUnit.MILLISECONDS);

Review Comment:
   Is it necessary to extend the waiting time here?



-- 
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: issues-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4450] Add retry strategy for sourceWorker. (eventmesh)

Posted by "fabian4 (via GitHub)" <gi...@apache.org>.
fabian4 commented on code in PR #4451:
URL: https://github.com/apache/eventmesh/pull/4451#discussion_r1330075350


##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -177,19 +179,30 @@ public void startPollAndSend() {
             // todo: convert connectRecord to cloudevent
             CloudEvent event = convertRecordToEvent(connectRecord);
             Optional<RecordOffsetManagement.SubmittedPosition> submittedRecordPosition = prepareToUpdateRecordOffset(connectRecord);
-            Package sendResult = eventMeshTCPClient.publish(event, 3000);
 
-            if (sendResult.getHeader().getCode() == 0) {
-                // publish success
-                // commit record
-                this.source.commit(connectRecord);
-                submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
-            } else {
-                // todo: retry or other strategy
-                log.error("{} failed to send record to {}, failed record {}", this, event.getSubject(), connectRecord);
+            int retryTimes = 0;
+            // retry until MAX_RETRY_TIMES is reached
+            while (retryTimes < MAX_RETRY_TIMES) {
+                try {
+                    Package sendResult = eventMeshTCPClient.publish(event, 3000);
+                    if (sendResult.getHeader().getCode() == 0) {
+                        // publish success
+                        // commit record
+                        this.source.commit(connectRecord);
+                        submittedRecordPosition.ifPresent(RecordOffsetManagement.SubmittedPosition::ack);
+                        break;
+                    }
+                    retryTimes++;
+                    log.warn("{} failed to send record to {}, retry times = {}, failed record {}",
+                            this, event.getSubject(), retryTimes, connectRecord);
+                } catch (Throwable t) {
+                    retryTimes++;
+                    log.error("{} failed to send record to {}, retry times = {}, failed record {}, throw {}",
+                            this, event.getSubject(), retryTimes, connectRecord, t.getMessage());
+                }
             }
 
-            offsetManagement.awaitAllMessages(5000, TimeUnit.MILLISECONDS);
+            offsetManagement.awaitAllMessages(15000, TimeUnit.MILLISECONDS);

Review Comment:
   assuming it succeed at last try?



-- 
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: issues-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org