Adding a route at the point when the Component is started is not such a
good idea as it leads to ConcurrentModificationException:
Caused by: java.util.ConcurrentModificationException: null
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
at java.util.ArrayList$Itr.next(ArrayList.java:851)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3713)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3428)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:208)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3236)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3232)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3255)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3232)
That is a new RouteDefinition is added while DefaultCamelContext
iterates over existing route routeDefinitions.
The new implementation reuses the base component created by the
connector component and cleverly avoids another processor needed to set
the headers (sObjectName and sObjectId) needed by the Salesforce
component by having SalesforceIdentifier::toString return the ID which
will be consumed from the incoming message body and setting
sObjectName as endpoint URI property.
Adding a route at the point when the Component is started is not such a good idea as it leads to ConcurrentModificationException:
That is a new
RouteDefinition
is added whileDefaultCamelContext
iterates over existing routerouteDefinitions
.The new implementation reuses the base component created by the connector component and cleverly avoids another processor needed to set the headers (
sObjectName
andsObjectId
) needed by the Salesforce component by havingSalesforceIdentifier::toString
return the ID which will be consumed from the incoming message body and settingsObjectName
as endpoint URI property.