[
https://issues.apache.org/jira/browse/CAMEL-19161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17701560#comment-17701560
]
Nicolas Filotto commented on CAMEL-19161:
-----------------------------------------
I could reproduce it with a simple test of the following type (with real
credentials):
{code:java}
class LazyConnectTest extends CamelTestSupport {
@Test
void lazyConnect() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:events");
mock.expectedMessageCount(1);
mock.assertIsSatisfied();
}
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = super.createCamelContext();
SalesforceEndpointConfig salesforceEndpointConfig = new
SalesforceEndpointConfig();
KeyStoreParameters ksp = new KeyStoreParameters();
SalesforceLoginConfig salesforceLoginConfig = new
SalesforceLoginConfig();
ksp.setResource("XXX.jks");
ksp.setPassword("YYY");
ksp.setType("JKS");
salesforceEndpointConfig.setApiVersion("52.0");
salesforceEndpointConfig.setRawPayload(true);
salesforceLoginConfig.setLoginUrl("https://login.salesforce.com/");
salesforceLoginConfig.setType(AuthenticationType.JWT);
salesforceLoginConfig.setClientId("ZZZZ");
salesforceLoginConfig.setClientSecret("AAAA");
salesforceLoginConfig.setUserName("BBB");
salesforceLoginConfig.setLazyLogin(true);
salesforceLoginConfig.setKeystore(ksp);
SalesforceComponent salesforceComponent =
camelContext.getComponent("salesforce", SalesforceComponent.class);
salesforceComponent.setLoginConfig(salesforceLoginConfig);
salesforceComponent.setConfig(salesforceEndpointConfig);
return camelContext;
}
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("salesforce:subscribe:event/Account_Event__e?replayId=-1")
.log("Received: ${body}")
.to("mock:events");
}
};
}
}
{code}
> camel-salesforce - Connection issue when using lazy login
> ---------------------------------------------------------
>
> Key: CAMEL-19161
> URL: https://issues.apache.org/jira/browse/CAMEL-19161
> Project: Camel
> Issue Type: Bug
> Components: camel-salesforce
> Affects Versions: 3.11.1
> Reporter: Nicolas Filotto
> Priority: Minor
>
> When we enable lazy login, we end up with an exception of type:
> {noformat}
> 2023-03-16 16:49:40,743 [main ] WARN SalesforceComponent
> - Missing property packages, getSObject* operations will NOT work without
> property rawPayload=true
> 2023-03-16 16:49:53,432 [main ] INFO SalesforceSession
> - Login at Salesforce loginUrl:
> https://login.salesforce.com/services/oauth2/token
> 2023-03-16 16:50:28,009 [main ] INFO SalesforceSession
> - Login successful
> 2023-03-16 16:50:33,456 [forceHttpClient] WARN SubscriptionHelper
> - Handshake failure: {failure={exception=java.lang.IllegalArgumentException:
> Invalid protocol null, message={ext={replay=true},
> supportedConnectionTypes=[long-polling], channel=/meta/handshake, id=1,
> version=1.0}, connectionType=long-polling}, channel=/meta/handshake, id=1,
> successful=false}
> 2023-03-16 16:50:33,457 [forceHttpClient] INFO SubscriptionHelper
> - Handshaking after unexpected disconnect from Salesforce...
> 2023-03-16 16:50:57,019 [forceHttpClient] WARN SubscriptionHelper
> - Handshake failure: {failure={exception=java.lang.IllegalArgumentException:
> Invalid protocol null, message={ext={replay=true},
> supportedConnectionTypes=[long-polling], channel=/meta/handshake, id=2,
> version=1.0}, connectionType=long-polling}, channel=/meta/handshake, id=2,
> successful=false}
> 2023-03-16 16:51:00,769 [forceHttpClient] WARN SubscriptionHelper
> - Handshake failure: {failure={exception=java.lang.IllegalArgumentException:
> Invalid protocol null, message={ext={replay=true},
> supportedConnectionTypes=[long-polling], channel=/meta/handshake, id=3,
> version=1.0}, connectionType=long-polling}, channel=/meta/handshake, id=3,
> successful=false}
> {noformat}
> After a deeper investigation, it is due to the fact that when [creating the
> {{BayeuxClient}} during
> startup|https://github.com/apache/camel/blob/main/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/streaming/SubscriptionHelper.java#L405],
> it calls {{component.getSession().getInstanceUrl()}} to build the Url used
> by the client to connect but the instance Url is null as long as it not
> connected.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)