You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "lorenzobenvenuti (via GitHub)" <gi...@apache.org> on 2025/06/18 12:37:56 UTC

[PR] Salesforce component: removed initial replay id check [camel]

lorenzobenvenuti opened a new pull request, #18396:
URL: https://github.com/apache/camel/pull/18396

   # Description
   
   See https://issues.apache.org/jira/browse/CAMEL-22173
   
   # Target
   
   - [ ] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch)
   
   For now the MR is targeting 4.10.x because it's easier for me to test the fix in our app
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue]
   
   https://issues.apache.org/jira/browse/CAMEL-22173
   
   # Apache Camel coding standards and style
   
   - [ ] I checked that each commit in the pull request has a meaningful subject line and body.
   
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes.
   


-- 
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@camel.apache.org

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


Re: [PR] Salesforce component: removed initial replay id check [camel]

Posted by "lorenzobenvenuti (via GitHub)" <gi...@apache.org>.
lorenzobenvenuti commented on PR #18396:
URL: https://github.com/apache/camel/pull/18396#issuecomment-3031259442

   Thanks for your feedback! As I mentioned in the Jira US, I had a few ideas about how to handle errors without stopping the route. I've pushed some changes with the second option: if the replay id is invalid, when `fallbackToLatestReplayId` is set then the consumer re-subscribes using `ReplayPreset.LATEST`; otherwise, an exception is passed to the consumer `ExceptionHandler` and no other action is taken. This means that the consumer will retry to subscribe with the same id and it will likely receive other errors, but if users want to stop the route they can plug a `BridgeExceptionHandlerToErrorHandler` and handle an `InvalidReplayIdException` in the route exception handler. LMK your thoughts. Meanwhile, I'll try to implement a couple of integration tests.
   
   Thanks,
   
   lorenzo


-- 
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@camel.apache.org

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


Re: [PR] Salesforce component: removed initial replay id check [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #18396:
URL: https://github.com/apache/camel/pull/18396#discussion_r2182518899


##########
components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/PubSubApiClient.java:
##########
@@ -407,10 +350,22 @@ public void onError(Throwable throwable) {
                             LOG.debug("logged in {}", consumer.getTopic());
                         }
                         case PUBSUB_ERROR_CORRUPTED_REPLAY_ID -> {
-                            LOG.error("replay id: " + replayId
-                                      + " is corrupt. Trying to recover by resubscribing with LATEST replay preset");
-                            replayId = null;
-                            initialReplayPreset = ReplayPreset.LATEST;
+                            String currReplayId = null;
+                            if (replayId != null) {
+                                currReplayId = replayId;
+                            } else if (initialReplayPreset == ReplayPreset.CUSTOM) {
+                                currReplayId = initialReplayId;
+                            }
+                            if (fallbackToLatestReplayId) {
+                                initialReplayPreset = ReplayPreset.LATEST;
+                                LOG.error("replay id: " + currReplayId

Review Comment:
   LOG.warn



##########
components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpoint.java:
##########
@@ -72,6 +72,13 @@ public class SalesforceEndpoint extends DefaultEndpoint {
     @UriParam(label = "consumer", description = "The replayId value to use when subscribing to the Pub/Sub API.")
     private String pubSubReplayId;
 
+    @UriParam(label = "consumer",
+              description = "Whether the pub/sub consumer needs to fallback to the latest replay id when the provided id is not valid. "
+                            + "If set to false, the component will keep retrying; in order to treat this as an exception you can "
+                            + "use BridgeExceptionHandlerToErrorHandler and handle the exception in the route.",
+              defaultValue = "false")
+    private boolean fallbackToLatestReplayId = false;

Review Comment:
   Remove `= false`



##########
components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/PubSubApiClient.java:
##########
@@ -407,10 +350,22 @@ public void onError(Throwable throwable) {
                             LOG.debug("logged in {}", consumer.getTopic());
                         }
                         case PUBSUB_ERROR_CORRUPTED_REPLAY_ID -> {
-                            LOG.error("replay id: " + replayId
-                                      + " is corrupt. Trying to recover by resubscribing with LATEST replay preset");
-                            replayId = null;
-                            initialReplayPreset = ReplayPreset.LATEST;
+                            String currReplayId = null;
+                            if (replayId != null) {
+                                currReplayId = replayId;
+                            } else if (initialReplayPreset == ReplayPreset.CUSTOM) {
+                                currReplayId = initialReplayId;
+                            }
+                            if (fallbackToLatestReplayId) {
+                                initialReplayPreset = ReplayPreset.LATEST;
+                                LOG.error("replay id: " + currReplayId
+                                          + " is corrupt. Trying to recover by resubscribing with LATEST replay preset");
+                                replayId = null;
+                            } else {
+                                consumer.getExceptionHandler().handleException(new InvalidReplayIdException(
+                                        "Invalid replay id: " + currReplayId,

Review Comment:
   Maybe use the same word as above, that its corrupt, sine the error case is  ERROR_CORRPUTED 



-- 
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@camel.apache.org

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


Re: [PR] Salesforce component: removed initial replay id check [camel]

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


-- 
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@camel.apache.org

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


Re: [PR] Salesforce component: removed initial replay id check [camel]

Posted by "lorenzobenvenuti (via GitHub)" <gi...@apache.org>.
lorenzobenvenuti commented on PR #18396:
URL: https://github.com/apache/camel/pull/18396#issuecomment-3031701866

   I've added a couple of integration tests and moved the `fallbackToLatestReplayId` to the endpoint (I thought it was a better option in case someone has multiple subscribers and wants to configure different behaviors); as mentioned earlier, this branch comes from `camel-4.10.x` because that's what we're using and I wanted to be able to test the changes in our application without introducing other variables, but if you think that the code looks good I'll rebase the MR and target `main`. Thanks!


-- 
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@camel.apache.org

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


Re: [PR] Salesforce component: removed initial replay id check [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #18396:
URL: https://github.com/apache/camel/pull/18396#issuecomment-3031265329

   Thanks, it would be great if you can get this done today/tomorrow as we cut Camel 4.13 in the weekend and it would be good to get this included in that release. 


-- 
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@camel.apache.org

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


Re: [PR] Salesforce component: removed initial replay id check [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #18396:
URL: https://github.com/apache/camel/pull/18396#issuecomment-3032761839

   /component-test camel-salesforce


-- 
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@camel.apache.org

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


Re: [PR] Salesforce component: removed initial replay id check [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #18396:
URL: https://github.com/apache/camel/pull/18396#issuecomment-3031889562

   Just some small things. Yeah the code looks good. You are welcome to target main branch either as new PR or change this


-- 
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@camel.apache.org

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


Re: [PR] Salesforce component: removed initial replay id check [camel]

Posted by "lorenzobenvenuti (via GitHub)" <gi...@apache.org>.
lorenzobenvenuti commented on PR #18396:
URL: https://github.com/apache/camel/pull/18396#issuecomment-3032730595

   I've updated the PR, using `main` as the target branch, and addressed the comments. Thanks!


-- 
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@camel.apache.org

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


Re: [PR] Salesforce component: removed initial replay id check [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18396:
URL: https://github.com/apache/camel/pull/18396#issuecomment-3032763168

   :robot: The Apache Camel test robot will run the tests for you :+1:


-- 
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@camel.apache.org

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


Re: [PR] Salesforce component: removed initial replay id check [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #18396:
URL: https://github.com/apache/camel/pull/18396#issuecomment-3030889501

   There is a bit of TODO in this code. The old option can be marked as `@Deprecated` at first for older releases. 
   The code that stops the route is also debateable as no other components does that. Its better to let the route keep erroring as its not possible to subscribe to that topic. So maybe log a WARN instead.


-- 
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@camel.apache.org

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


Re: [PR] Salesforce component: removed initial replay id check [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18396:
URL: https://github.com/apache/camel/pull/18396#issuecomment-2984031511

   :star2: Thank you for your contribution to the Apache Camel project! :star2: 
   
   :robot: CI automation will test this PR automatically.
   
   :camel: Apache Camel Committers, please review the following items:
   
   * First-time contributors **require MANUAL approval** for the GitHub Actions to run
   
   * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot.
   
   * You can label PRs using `build-all`, `build-dependents`, `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
   
   * Build and test logs are available in the Summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary. 
   
   * :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
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@camel.apache.org

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