You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by je...@apache.org on 2024/10/23 19:48:13 UTC

(camel) branch main updated (4890458c30c -> 9a0de750a8f)

This is an automated email from the ASF dual-hosted git repository.

jeremyross pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from 4890458c30c Fix xref
     new d49586b851d CAMEL-21379: camel-salesforce: introduce delay in pub/sub reconnect attempts
     new 9a0de750a8f CAMEL-21380: camel-salesforce: pubsub: ability to opt out of system proxy

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../codegen/AbstractSalesforceExecution.java       |  2 +-
 .../salesforce/SalesforceComponentConfigurer.java  |  6 +++
 .../camel/component/salesforce/salesforce.json     | 45 +++++++++++-----------
 .../component/salesforce/PubSubApiConsumer.java    |  3 +-
 .../component/salesforce/SalesforceComponent.java  | 13 +++++++
 .../internal/client/PubSubApiClient.java           | 21 +++++++++-
 .../internal/processor/PubSubApiProcessor.java     |  3 +-
 .../component/salesforce/PubSubApiManualIT.java    |  2 +-
 .../camel/component/salesforce/PubSubApiTest.java  | 18 +++++----
 9 files changed, 77 insertions(+), 36 deletions(-)


(camel) 02/02: CAMEL-21380: camel-salesforce: pubsub: ability to opt out of system proxy

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jeremyross pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9a0de750a8f8d5099518178990869a89b5660c9c
Author: Jeremy Ross <je...@gmail.com>
AuthorDate: Wed Oct 23 12:15:56 2024 -0500

    CAMEL-21380: camel-salesforce: pubsub: ability to opt out of system proxy
---
 .../codegen/AbstractSalesforceExecution.java       |  2 +-
 .../salesforce/SalesforceComponentConfigurer.java  |  6 +++
 .../camel/component/salesforce/salesforce.json     | 45 +++++++++++-----------
 .../component/salesforce/PubSubApiConsumer.java    |  3 +-
 .../component/salesforce/SalesforceComponent.java  | 13 +++++++
 .../internal/client/PubSubApiClient.java           |  8 +++-
 .../internal/processor/PubSubApiProcessor.java     |  3 +-
 .../component/salesforce/PubSubApiManualIT.java    |  2 +-
 .../camel/component/salesforce/PubSubApiTest.java  | 12 +++---
 9 files changed, 61 insertions(+), 33 deletions(-)

diff --git a/components/camel-salesforce/camel-salesforce-codegen/src/main/java/org/apache/camel/component/salesforce/codegen/AbstractSalesforceExecution.java b/components/camel-salesforce/camel-salesforce-codegen/src/main/java/org/apache/camel/component/salesforce/codegen/AbstractSalesforceExecution.java
index 716f19a6669..015b0cb3a3e 100644
--- a/components/camel-salesforce/camel-salesforce-codegen/src/main/java/org/apache/camel/component/salesforce/codegen/AbstractSalesforceExecution.java
+++ b/components/camel-salesforce/camel-salesforce-codegen/src/main/java/org/apache/camel/component/salesforce/codegen/AbstractSalesforceExecution.java
@@ -217,7 +217,7 @@ public abstract class AbstractSalesforceExecution {
         if (pubSubApiClient != null) {
             return pubSubApiClient;
         }
-        pubSubApiClient = new PubSubApiClient(session, new SalesforceLoginConfig(), pubSubHost, pubSubPort, 0, 0);
+        pubSubApiClient = new PubSubApiClient(session, new SalesforceLoginConfig(), pubSubHost, pubSubPort, 0, 0, true);
         pubSubApiClient.start();
         return pubSubApiClient;
     }
diff --git a/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceComponentConfigurer.java b/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceComponentConfigurer.java
index e6e536d62da..18ecad5c231 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceComponentConfigurer.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceComponentConfigurer.java
@@ -171,6 +171,8 @@ public class SalesforceComponentConfigurer extends PropertyConfigurerSupport imp
         case "pubSubPojoClass": getOrCreateConfig(target).setPubSubPojoClass(property(camelContext, java.lang.String.class, value)); return true;
         case "pubsubport":
         case "pubSubPort": target.setPubSubPort(property(camelContext, int.class, value)); return true;
+        case "pubsuballowusesystemproxy":
+        case "pubsubAllowUseSystemProxy": target.setPubsubAllowUseSystemProxy(property(camelContext, boolean.class, value)); return true;
         case "querylocator":
         case "queryLocator": getOrCreateConfig(target).setQueryLocator(property(camelContext, java.lang.String.class, value)); return true;
         case "rawhttpheaders":
@@ -373,6 +375,8 @@ public class SalesforceComponentConfigurer extends PropertyConfigurerSupport imp
         case "pubSubPojoClass": return java.lang.String.class;
         case "pubsubport":
         case "pubSubPort": return int.class;
+        case "pubsuballowusesystemproxy":
+        case "pubsubAllowUseSystemProxy": return boolean.class;
         case "querylocator":
         case "queryLocator": return java.lang.String.class;
         case "rawhttpheaders":
@@ -576,6 +580,8 @@ public class SalesforceComponentConfigurer extends PropertyConfigurerSupport imp
         case "pubSubPojoClass": return getOrCreateConfig(target).getPubSubPojoClass();
         case "pubsubport":
         case "pubSubPort": return target.getPubSubPort();
+        case "pubsuballowusesystemproxy":
+        case "pubsubAllowUseSystemProxy": return target.isPubsubAllowUseSystemProxy();
         case "querylocator":
         case "queryLocator": return getOrCreateConfig(target).getQueryLocator();
         case "rawhttpheaders":
diff --git a/components/camel-salesforce/camel-salesforce-component/src/generated/resources/META-INF/org/apache/camel/component/salesforce/salesforce.json b/components/camel-salesforce/camel-salesforce-component/src/generated/resources/META-INF/org/apache/camel/component/salesforce/salesforce.json
index 150b76bc033..e55aca1b198 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/generated/resources/META-INF/org/apache/camel/component/salesforce/salesforce.json
+++ b/components/camel-salesforce/camel-salesforce-component/src/generated/resources/META-INF/org/apache/camel/component/salesforce/salesforce.json
@@ -104,28 +104,29 @@
     "httpProxyIncludedAddresses": { "index": 76, "kind": "property", "displayName": "Http Proxy Included Addresses", "group": "proxy", "label": "common,proxy", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "A list of addresses for which HTTP proxy server should be used." },
     "httpProxyPort": { "index": 77, "kind": "property", "displayName": "Http Proxy Port", "group": "proxy", "label": "common,proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Port number of the HTTP proxy server to use." },
     "httpProxySocks4": { "index": 78, "kind": "property", "displayName": "Http Proxy Socks4", "group": "proxy", "label": "common,proxy", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true the configures the HTTP proxy to use as a SOCKS4 proxy." },
-    "authenticationType": { "index": 79, "kind": "property", "displayName": "Authentication Type", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.component.salesforce.AuthenticationType", "enum": [ "USERNAME_PASSWORD", "REFRESH_TOKEN", "CLIENT_CREDENTIALS", "JWT" ], "deprecated": false, "autowired": false, "secret": false, "description": "Explicit authentication method to be used, one of USERNAME_PASSWORD, REFRESH_TOKEN [...]
-    "clientId": { "index": 80, "kind": "property", "displayName": "Client Id", "group": "security", "label": "common,security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "OAuth Consumer Key of the connected app configured in the Salesforce instance setup. Typically a connected app needs to be configured but one can be provided by installing a package." },
-    "clientSecret": { "index": 81, "kind": "property", "displayName": "Client Secret", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "OAuth Consumer Secret of the connected app configured in the Salesforce instance setup." },
-    "httpProxyAuthUri": { "index": 82, "kind": "property", "displayName": "Http Proxy Auth Uri", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Used in authentication against the HTTP proxy server, needs to match the URI of the proxy server in order for the httpProxyUsername and httpProxyPassword to be used for authentication." },
-    "httpProxyPassword": { "index": 83, "kind": "property", "displayName": "Http Proxy Password", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Password to use to authenticate against the HTTP proxy server." },
-    "httpProxyRealm": { "index": 84, "kind": "property", "displayName": "Http Proxy Realm", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Realm of the proxy server, used in preemptive Basic\/Digest authentication methods against the HTTP proxy server." },
-    "httpProxySecure": { "index": 85, "kind": "property", "displayName": "Http Proxy Secure", "group": "security", "label": "common,proxy,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If set to false disables the use of TLS when accessing the HTTP proxy." },
-    "httpProxyUseDigestAuth": { "index": 86, "kind": "property", "displayName": "Http Proxy Use Digest Auth", "group": "security", "label": "common,proxy,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true Digest authentication will be used when authenticating to the HTTP proxy, otherwise Basic authorization method will be used" },
-    "httpProxyUsername": { "index": 87, "kind": "property", "displayName": "Http Proxy Username", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Username to use to authenticate against the HTTP proxy server." },
-    "instanceUrl": { "index": 88, "kind": "property", "displayName": "Instance Url", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "URL of the Salesforce instance used after authentication, by default received from Salesforce on successful authentication" },
-    "jwtAudience": { "index": 89, "kind": "property", "displayName": "Jwt Audience", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Value to use for the Audience claim (aud) when using OAuth JWT flow. If not set, the login URL will be used, which is appropriate in most cases." },
-    "keystore": { "index": 90, "kind": "property", "displayName": "Keystore", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.KeyStoreParameters", "deprecated": false, "autowired": false, "secret": false, "description": "KeyStore parameters to use in OAuth JWT flow. The KeyStore should contain only one entry with private key and certificate. Salesforce does not verify the certificate chain, so this can easil [...]
-    "lazyLogin": { "index": 91, "kind": "property", "displayName": "Lazy Login", "group": "security", "label": "common,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true prevents the component from authenticating to Salesforce with the start of the component. You would generally set this to the (default) false and authenticate early and be immediately aware [...]
-    "loginConfig": { "index": 92, "kind": "property", "displayName": "Login Config", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.component.salesforce.SalesforceLoginConfig", "deprecated": false, "autowired": false, "secret": false, "description": "All authentication configuration in one nested bean, all properties set there can be set directly on the component as well" },
-    "loginUrl": { "index": 93, "kind": "property", "displayName": "Login Url", "group": "security", "label": "common,security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "https:\/\/login.salesforce.com", "description": "URL of the Salesforce instance used for authentication, by default set to https:\/\/login.salesforce.com" },
-    "password": { "index": 94, "kind": "property", "displayName": "Password", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Password used in OAuth flow to gain access to access token. It's easy to get started with password OAuth flow, but in general one should avoid it as it is deemed less secure than other flows. Make sure that you append secur [...]
-    "pubSubHost": { "index": 95, "kind": "property", "displayName": "Pub Sub Host", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "api.pubsub.salesforce.com", "description": "Pub\/Sub host" },
-    "pubSubPort": { "index": 96, "kind": "property", "displayName": "Pub Sub Port", "group": "security", "label": "common,security", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 7443, "description": "Pub\/Sub port" },
-    "refreshToken": { "index": 97, "kind": "property", "displayName": "Refresh Token", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Refresh token already obtained in the refresh token OAuth flow. One needs to setup a web application and configure a callback URL to receive the refresh token, or configure using the builtin callback at https:\/\/l [...]
-    "sslContextParameters": { "index": 98, "kind": "property", "displayName": "Ssl Context Parameters", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false, "autowired": false, "secret": false, "description": "SSL parameters to use, see SSLContextParameters class for all available options." },
-    "useGlobalSslContextParameters": { "index": 99, "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters" },
-    "userName": { "index": 100, "kind": "property", "displayName": "User Name", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Username used in OAuth flow to gain access to access token. It's easy to get started with password OAuth flow, but in general one should avoid it as it is deemed less secure than other flows." }
+    "pubsubAllowUseSystemProxy": { "index": 79, "kind": "property", "displayName": "Pubsub Allow Use System Proxy", "group": "proxy", "label": "common,proxy", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Allow the Pub\/Sub API client to use the proxy detected by java.net.ProxySelector. If false then no proxy server will be used." },
+    "authenticationType": { "index": 80, "kind": "property", "displayName": "Authentication Type", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.component.salesforce.AuthenticationType", "enum": [ "USERNAME_PASSWORD", "REFRESH_TOKEN", "CLIENT_CREDENTIALS", "JWT" ], "deprecated": false, "autowired": false, "secret": false, "description": "Explicit authentication method to be used, one of USERNAME_PASSWORD, REFRESH_TOKEN [...]
+    "clientId": { "index": 81, "kind": "property", "displayName": "Client Id", "group": "security", "label": "common,security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "OAuth Consumer Key of the connected app configured in the Salesforce instance setup. Typically a connected app needs to be configured but one can be provided by installing a package." },
+    "clientSecret": { "index": 82, "kind": "property", "displayName": "Client Secret", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "OAuth Consumer Secret of the connected app configured in the Salesforce instance setup." },
+    "httpProxyAuthUri": { "index": 83, "kind": "property", "displayName": "Http Proxy Auth Uri", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Used in authentication against the HTTP proxy server, needs to match the URI of the proxy server in order for the httpProxyUsername and httpProxyPassword to be used for authentication." },
+    "httpProxyPassword": { "index": 84, "kind": "property", "displayName": "Http Proxy Password", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Password to use to authenticate against the HTTP proxy server." },
+    "httpProxyRealm": { "index": 85, "kind": "property", "displayName": "Http Proxy Realm", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Realm of the proxy server, used in preemptive Basic\/Digest authentication methods against the HTTP proxy server." },
+    "httpProxySecure": { "index": 86, "kind": "property", "displayName": "Http Proxy Secure", "group": "security", "label": "common,proxy,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If set to false disables the use of TLS when accessing the HTTP proxy." },
+    "httpProxyUseDigestAuth": { "index": 87, "kind": "property", "displayName": "Http Proxy Use Digest Auth", "group": "security", "label": "common,proxy,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true Digest authentication will be used when authenticating to the HTTP proxy, otherwise Basic authorization method will be used" },
+    "httpProxyUsername": { "index": 88, "kind": "property", "displayName": "Http Proxy Username", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Username to use to authenticate against the HTTP proxy server." },
+    "instanceUrl": { "index": 89, "kind": "property", "displayName": "Instance Url", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "URL of the Salesforce instance used after authentication, by default received from Salesforce on successful authentication" },
+    "jwtAudience": { "index": 90, "kind": "property", "displayName": "Jwt Audience", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Value to use for the Audience claim (aud) when using OAuth JWT flow. If not set, the login URL will be used, which is appropriate in most cases." },
+    "keystore": { "index": 91, "kind": "property", "displayName": "Keystore", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.KeyStoreParameters", "deprecated": false, "autowired": false, "secret": false, "description": "KeyStore parameters to use in OAuth JWT flow. The KeyStore should contain only one entry with private key and certificate. Salesforce does not verify the certificate chain, so this can easil [...]
+    "lazyLogin": { "index": 92, "kind": "property", "displayName": "Lazy Login", "group": "security", "label": "common,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true prevents the component from authenticating to Salesforce with the start of the component. You would generally set this to the (default) false and authenticate early and be immediately aware [...]
+    "loginConfig": { "index": 93, "kind": "property", "displayName": "Login Config", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.component.salesforce.SalesforceLoginConfig", "deprecated": false, "autowired": false, "secret": false, "description": "All authentication configuration in one nested bean, all properties set there can be set directly on the component as well" },
+    "loginUrl": { "index": 94, "kind": "property", "displayName": "Login Url", "group": "security", "label": "common,security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "https:\/\/login.salesforce.com", "description": "URL of the Salesforce instance used for authentication, by default set to https:\/\/login.salesforce.com" },
+    "password": { "index": 95, "kind": "property", "displayName": "Password", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Password used in OAuth flow to gain access to access token. It's easy to get started with password OAuth flow, but in general one should avoid it as it is deemed less secure than other flows. Make sure that you append secur [...]
+    "pubSubHost": { "index": 96, "kind": "property", "displayName": "Pub Sub Host", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "api.pubsub.salesforce.com", "description": "Pub\/Sub host" },
+    "pubSubPort": { "index": 97, "kind": "property", "displayName": "Pub Sub Port", "group": "security", "label": "common,security", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 7443, "description": "Pub\/Sub port" },
+    "refreshToken": { "index": 98, "kind": "property", "displayName": "Refresh Token", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Refresh token already obtained in the refresh token OAuth flow. One needs to setup a web application and configure a callback URL to receive the refresh token, or configure using the builtin callback at https:\/\/l [...]
+    "sslContextParameters": { "index": 99, "kind": "property", "displayName": "Ssl Context Parameters", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false, "autowired": false, "secret": false, "description": "SSL parameters to use, see SSLContextParameters class for all available options." },
+    "useGlobalSslContextParameters": { "index": 100, "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters" },
+    "userName": { "index": 101, "kind": "property", "displayName": "User Name", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Username used in OAuth flow to gain access to access token. It's easy to get started with password OAuth flow, but in general one should avoid it as it is deemed less secure than other flows." }
   },
   "headers": {
     "CamelSalesforceReplayId": { "index": 0, "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Streaming API replayId.", "constantName": "org.apache.camel.component.salesforce.SalesforceConstants#HEADER_SALESFORCE_REPLAY_ID" },
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/PubSubApiConsumer.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/PubSubApiConsumer.java
index 17f65fdbf56..6db8ce247e3 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/PubSubApiConsumer.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/PubSubApiConsumer.java
@@ -83,7 +83,8 @@ public class PubSubApiConsumer extends DefaultConsumer {
         this.pubSubClient = new PubSubApiClient(
                 endpoint.getComponent().getSession(), endpoint.getComponent().getLoginConfig(),
                 endpoint.getComponent().getPubSubHost(), endpoint.getComponent().getPubSubPort(),
-                endpoint.getConfiguration().getBackoffIncrement(), endpoint.getConfiguration().getMaxBackoff());
+                endpoint.getConfiguration().getBackoffIncrement(), endpoint.getConfiguration().getMaxBackoff(),
+                endpoint.getComponent().isPubsubAllowUseSystemProxy());
         this.pubSubClient.setUsePlainTextConnection(this.usePlainTextConnection);
 
         ServiceHelper.startService(pubSubClient);
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
index 794e6b88240..09491f03cf7 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
@@ -173,6 +173,11 @@ public class SalesforceComponent extends DefaultComponent implements SSLContextP
               defaultValue = "7443", label = "common,security")
     private int pubSubPort = 7443;
 
+    @Metadata(description = "Allow the Pub/Sub API client to use the proxy detected by java.net.ProxySelector. If false then"
+                            + " no proxy server will be used.",
+              defaultValue = "true", label = "common,proxy")
+    private boolean pubsubAllowUseSystemProxy = true;
+
     @Metadata(description = "Global endpoint configuration - use to set values that are common to all endpoints",
               label = "common,advanced")
     private SalesforceEndpointConfig config;
@@ -786,6 +791,14 @@ public class SalesforceComponent extends DefaultComponent implements SSLContextP
         this.httpProxyUseDigestAuth = httpProxyUseDigestAuth;
     }
 
+    public boolean isPubsubAllowUseSystemProxy() {
+        return pubsubAllowUseSystemProxy;
+    }
+
+    public void setPubsubAllowUseSystemProxy(boolean pubsubAllowUseSystemProxy) {
+        this.pubsubAllowUseSystemProxy = pubsubAllowUseSystemProxy;
+    }
+
     public int getWorkerPoolSize() {
         return workerPoolSize;
     }
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/PubSubApiClient.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/PubSubApiClient.java
index 8ba356d4814..ed3c911a0d0 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/PubSubApiClient.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/PubSubApiClient.java
@@ -83,6 +83,7 @@ public class PubSubApiClient extends ServiceSupport {
     private long reconnectDelay;
     private final String pubSubHost;
     private final int pubSubPort;
+    private final boolean allowUseProxyServer;
 
     private final Logger LOG = LoggerFactory.getLogger(getClass());
     private final SalesforceLoginConfig loginConfig;
@@ -100,7 +101,7 @@ public class PubSubApiClient extends ServiceSupport {
     private String initialReplayId;
 
     public PubSubApiClient(SalesforceSession session, SalesforceLoginConfig loginConfig, String pubSubHost,
-                           int pubSubPort, long backoffIncrement, long maxBackoff) {
+                           int pubSubPort, long backoffIncrement, long maxBackoff, boolean allowUseProxyServer) {
         this.session = session;
         this.loginConfig = loginConfig;
         this.pubSubHost = pubSubHost;
@@ -108,6 +109,8 @@ public class PubSubApiClient extends ServiceSupport {
         this.maxBackoff = maxBackoff;
         this.backoffIncrement = backoffIncrement;
         this.reconnectDelay = backoffIncrement;
+        this.allowUseProxyServer = allowUseProxyServer;
+
     }
 
     public List<org.apache.camel.component.salesforce.api.dto.pubsub.PublishResult> publishMessage(
@@ -203,6 +206,9 @@ public class PubSubApiClient extends ServiceSupport {
 
         final ManagedChannelBuilder<?> channelBuilder = ManagedChannelBuilder
                 .forAddress(pubSubHost, pubSubPort);
+        if (!allowUseProxyServer) {
+            channelBuilder.proxyDetector(socketAddress -> null);
+        }
         if (usePlainTextConnection) {
             channelBuilder.usePlaintext();
         }
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/PubSubApiProcessor.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/PubSubApiProcessor.java
index c648309c4c9..d55bdbda07b 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/PubSubApiProcessor.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/PubSubApiProcessor.java
@@ -85,7 +85,8 @@ public class PubSubApiProcessor extends AbstractSalesforceProcessor {
         this.pubSubClient = new PubSubApiClient(
                 endpoint.getComponent().getSession(),
                 endpoint.getComponent().getLoginConfig(), endpoint.getComponent().getPubSubHost(),
-                endpoint.getComponent().getPubSubPort(), 0, 0);
+                endpoint.getComponent().getPubSubPort(), 0, 0,
+                endpoint.getComponent().isPubsubAllowUseSystemProxy());
         ServiceHelper.startService(pubSubClient);
     }
 
diff --git a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/PubSubApiManualIT.java b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/PubSubApiManualIT.java
index 87321b9de77..bf98679d6e7 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/PubSubApiManualIT.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/PubSubApiManualIT.java
@@ -212,7 +212,7 @@ public class PubSubApiManualIT extends AbstractSalesforceTestBase {
         try {
             client = new PubSubApiClient(
                     component.getSession(), new SalesforceLoginConfig(),
-                    "api.pubsub.salesforce.com", 7443, 0, 0);
+                    "api.pubsub.salesforce.com", 7443, 0, 0, true);
             client.start();
 
             byte[] bytes;
diff --git a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/PubSubApiTest.java b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/PubSubApiTest.java
index 04cb67b3cd5..52447d76abd 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/PubSubApiTest.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/PubSubApiTest.java
@@ -62,14 +62,14 @@ public class PubSubApiTest {
 
         PubSubApiClient client = Mockito.spy(new PubSubApiClient(
                 session, new SalesforceLoginConfig(), "localhost",
-                port, 1000, 10000));
+                port, 1000, 10000, true));
         client.setUsePlainTextConnection(true);
         client.start();
         client.subscribe(consumer, ReplayPreset.LATEST, null);
 
         verify(session, timeout(5000)).attemptLoginUntilSuccessful(anyLong(), anyLong());
-        verify(client, times(1)).subscribe(consumer, ReplayPreset.LATEST, null);
-        verify(client, times(1)).subscribe(consumer, ReplayPreset.CUSTOM, "MTIz");
+        verify(client, timeout(5000).times(1)).subscribe(consumer, ReplayPreset.LATEST, null);
+        verify(client, timeout(5000).times(1)).subscribe(consumer, ReplayPreset.CUSTOM, "MTIz");
     }
 
     @Test
@@ -92,7 +92,7 @@ public class PubSubApiTest {
 
         PubSubApiClient client = Mockito.spy(new PubSubApiClient(
                 session, new SalesforceLoginConfig(), "localhost",
-                port, 1000, 10000));
+                port, 1000, 10000, true));
         client.setUsePlainTextConnection(true);
         client.start();
         client.subscribe(consumer, ReplayPreset.CUSTOM, "initial");
@@ -121,7 +121,7 @@ public class PubSubApiTest {
 
         PubSubApiClient client = Mockito.spy(new PubSubApiClient(
                 session, new SalesforceLoginConfig(), "localhost",
-                port, 1000, 10000));
+                port, 1000, 10000, true));
         client.setUsePlainTextConnection(true);
         client.start();
         client.subscribe(consumer, ReplayPreset.LATEST, null);
@@ -152,7 +152,7 @@ public class PubSubApiTest {
 
         PubSubApiClient client = new PubSubApiClient(
                 session, new SalesforceLoginConfig(), "localhost",
-                port, 1000, 10000);
+                port, 1000, 10000, true);
         client.setUsePlainTextConnection(true);
         client.start();
         client.subscribe(consumer, ReplayPreset.LATEST, null);


(camel) 01/02: CAMEL-21379: camel-salesforce: introduce delay in pub/sub reconnect attempts

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jeremyross pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit d49586b851d8e096934b3ec8137a135d4643bcf3
Author: Jeremy Ross <je...@gmail.com>
AuthorDate: Wed Oct 23 13:07:52 2024 -0500

    CAMEL-21379: camel-salesforce: introduce delay in pub/sub reconnect attempts
---
 .../salesforce/internal/client/PubSubApiClient.java         | 13 ++++++++++++-
 .../apache/camel/component/salesforce/PubSubApiTest.java    |  6 ++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/PubSubApiClient.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/PubSubApiClient.java
index d6caba9b317..8ba356d4814 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/PubSubApiClient.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/PubSubApiClient.java
@@ -80,6 +80,7 @@ public class PubSubApiClient extends ServiceSupport {
 
     private final long backoffIncrement;
     private final long maxBackoff;
+    private long reconnectDelay;
     private final String pubSubHost;
     private final int pubSubPort;
 
@@ -106,6 +107,7 @@ public class PubSubApiClient extends ServiceSupport {
         this.pubSubPort = pubSubPort;
         this.maxBackoff = maxBackoff;
         this.backoffIncrement = backoffIncrement;
+        this.reconnectDelay = backoffIncrement;
     }
 
     public List<org.apache.camel.component.salesforce.api.dto.pubsub.PublishResult> publishMessage(
@@ -289,6 +291,9 @@ public class PubSubApiClient extends ServiceSupport {
 
         @Override
         public void onNext(FetchResponse fetchResponse) {
+            // reset reconnect delay in case we previously had errors
+            reconnectDelay = backoffIncrement;
+
             String topic = consumer.getTopic();
 
             LOG.debug("Received {} events on topic: {}", fetchResponse.getEventsList().size(), topic);
@@ -339,11 +344,17 @@ public class PubSubApiClient extends ServiceSupport {
             } else {
                 LOG.error("An unexpected error occurred.", throwable);
             }
-            LOG.debug("Attempting subscribe after error");
             resubscribeOnError();
         }
 
         private void resubscribeOnError() {
+            try {
+                LOG.debug("Will attempt resubscribe in {} ms", reconnectDelay);
+                Thread.sleep(reconnectDelay);
+                reconnectDelay = reconnectDelay + backoffIncrement;
+            } catch (InterruptedException e) {
+                throw new RuntimeException(e);
+            }
             if (replayId != null) {
                 subscribe(consumer, ReplayPreset.CUSTOM, replayId);
             } else {
diff --git a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/PubSubApiTest.java b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/PubSubApiTest.java
index 38b9533411f..04cb67b3cd5 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/PubSubApiTest.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/PubSubApiTest.java
@@ -98,7 +98,7 @@ public class PubSubApiTest {
         client.subscribe(consumer, ReplayPreset.CUSTOM, "initial");
 
         verify(session, timeout(5000)).attemptLoginUntilSuccessful(anyLong(), anyLong());
-        verify(client, times(2)).subscribe(consumer, ReplayPreset.CUSTOM, "initial");
+        verify(client, timeout(5000).times(2)).subscribe(consumer, ReplayPreset.CUSTOM, "initial");
     }
 
     @Test
@@ -126,8 +126,10 @@ public class PubSubApiTest {
         client.start();
         client.subscribe(consumer, ReplayPreset.LATEST, null);
 
+        Thread.sleep(1000);
+
         verify(session, timeout(5000)).attemptLoginUntilSuccessful(anyLong(), anyLong());
-        verify(client, times(2)).subscribe(consumer, ReplayPreset.LATEST, null);
+        verify(client, timeout(5000).times(2)).subscribe(consumer, ReplayPreset.LATEST, null);
     }
 
     @Test