It would be great if all camel components could be mixed-in in a spring-boot application without having to worry about dependencies.
This would allow users to choose the camel components in a tool like forge on fabric8 or spring initializr to produce a base artifact. Writing camel routes will be the only task left to the user.
Unfortunately, integration tests have shown that there are many (small, trivial) issues that need to be fixed before people can use a component with spring-boot (list follows).
A possible solution that will provide a better experience with spring-boot would be:
- Providing a new spring-boot bom
- Providing a spring-boot-starter project for each camel component
A user application pom will look like the following:
As suggested by chirino, the creation of such starters (and of the bom) could be automated. Rules for creating such artifacts will be (at least) the following:
The spring-boot-bom will be derived from camel-parent, with some exceptions to solve particular issues. Most of the starters will just include a dependency on the artifact they refer to.
Logging issues have been found during integration tests, but they will be solved on the main artifacts (see
CAMEL-10217). The starter generator will just check that logging implementation are missing from the artifact to prevent conflicts with slf4j-logback (used by spring-boot-starter).
2) Transitive overrides
Using the current implementation (with camel-parent in the BOM), whenever a component requires a library that is different from the one declared in camel-parent, some hacks should be done, because the definition in the BOM takes precedence.
Eg. An user wants to use camel-jclouds, but instead of the pretty:
He will end up with the following declaration in his application pom:
As a solution to this problem, if there are at least two components requiring eg. a different version of guava, guava will not be included in the spring-boot bom, instead the specific version will be enforced on each starter (for all components using guava).
Of course, this will not prevent issues when two components requiring different versions of guava will be used in the same user application. I think this issue cannot be avoided in applications with a standard classloader.
3) API implementations
In many cases, spring-boot detects the presence of a particular api in the classpath and expects an implementation is present. This happens for example with the bean validation api:
The starters will include eg. the Hibernate Validator each time it is required to start the application.
4) Optional dependencies as variants
Starters are often used to provide a full stack for some higher level libraries/api.
Eg. The JTA api can be provided in spring with three starters (as of 1.4.0):
Each starter will include everything that is necessary in terms of libraries and auto-configuration for the particular implementation.
Having such an automated tool for generating poms, we could create starters like:
Each one having everything needed to run routes described using rest dsl (auto-configuration included. It will probably be developed on the main component).
Similarly we can have:
The latter providing a preferred implementation and autoconfiguration (such as Narayana).
Each configuration will be checked by the already existing spring-boot integration tests. Support will be added for executing specific tests related to the a particular starter configuration, if needed.
In case of dependencies enforced by both camel-parent and spring-boot (with different versions), the camel-spring-boot BOM will use the spring-boot version. Problems will be highlighted by integration tests.
I started this Jira mainly to check if this feature can improve the user experience and if the points I highlighted are sound, before starting the implementation.
Probably there are also other issues/use-cases that I didn't cover in my list.