Even though SwitchYard is a new project, we have already enjoyed fantastic support from our community. Prior blog posts have highlighted the initial support for Camel and the addition of a JSON transformer. For this community spotlight post, I want to point out some work that Mario Antollini has done w/r/t Camel configuration.
Camel supports a wide array of components which accept configuration as a URI. For example, the following URI configures the Camel File component to consume files from the "/tmp/input" directory:
file:///tmp/input
You can't get much more convenient than that. This is one of the features that makes Camel such a joy to use. There are a couple of things to watch out for with URIs though. First, some components in the Camel community support a ton of config options. Let's take another look at a file config URI that uses a few more options:
file:///dev/inbound/purchaseOrders?autoCreate=false&bufferSize=1024&initialDelay=10&delete=true&readLockCheckInterval=1000&startingDirectoryMustExist=true&include=*.txt
The above config is a bit chattier and presents two potential challenges:
1) It's getting tough to parse with the naked eye, which makes reading or updating the config string a bit more error prone.
2) Validation in tooling is a challenge because we don't have a definition of which settings are allowed and what values those settings can take.
One way to address this is to define a schema for the component configuration and use that to structure the config parameters and validate them. Here's the same config URI represented as a gateway binding config:
<binding.file xmlns="urn:switchyard-component-camel:config:1.0">
<operationSelector operationName="someOperation"/>
<targetDir>/dev/inbound/purchaseOrders</camel:targetDir>
<autoCreate>false</camel:autoCreate>
<bufferSize>1024</camel:bufferSize>
<consume>
<initialDelay>10</camel:initialDelay>
<delete>false</camel:delete>
<readLockCheckInterval>1000</camel:readLockCheckInterval>
<startingDirectoryMustExist>true</camel:startingDirectoryMustExist>
<include>*.txt</include>
</consume>
</binding.file>
Mario has added configuration model support to parse, create, and validate a number of Camel component configs and more are being added. If you prefer the straight URI route, then that option is still available as well through the base camel binding configuration:
<binding.camel configURI="file:///tmp/input">
<camel:operationSelector operationName="print"/>
</camel:binding.camel>
Thanks Mario!