Prithiviraj Kandappan
Prithiviraj Kandappan

Reputation: 11

Which DSL to prefer on routing configuration in Apache Camel in large scale products, JAVA DSL / Spring XML?

We are in the design phase of the project and decided to use Apache Camel as the integration tool. Need help to decide which DSL is better suitable for the project (JAVA DSL or Spring XML), Would be grateful if you provide the pros, cons of the mentioned DSL and your stand on which to use in a summary.

Upvotes: 1

Views: 1005

Answers (1)

Pasi Österman
Pasi Österman

Reputation: 2167

Project consistency

Don't make these decisions solo (unless you're solo developer), use the one preferred by the team to make things consistent between integrations. If majority of integrations use Spring xml go with that and same for Java-DSL until there's consensus to change things up.

When projects fail to follow shared patterns, conventions, tools etc. the more difficult it will be for other developers to make changes, reuse code or analyse them in various ways.

Java-DSL vs Spring XML

Flexibility of Java-DSL

Java-dsl is generally the more flexible choice for developers but this is a bit of a double-edged sword as it also allows more inexperienced camel developers more easily to re-invent the wheel and solve problems that camel already solves or do some very hacky stuff with processors. Generally if your route just calls one big custom processors or multiple custom processors that's often sign to learn more about integration patterns.

Spring XML limitations can encourage users to look more in to what integration patterns and tools already exist and write more re-usable processors, converters and components. There's however chance that inexperienced developers start to mix Spring XML, Java-DSL and Java in ways that makes the logic overly complex and hard to follow.

Code completion, syntax highlighting and linting

Probably the biggest advantage Java-DSL has over Spring XML is code completion, error highlighting and linting. This makes it easier and faster to spot mistakes, typos and bad practices. With use of the new Endpoint DSL one can even construct URIs in type-safe manner with minimal string manipulation.

One big advantage Spring XML has over Java-DSL is that you could potentially use GUI for configuring camel routes. There's actually set of Eclipse plugins that includes this feature called Fuse Tooling however as many prefer IntelliJ or VSCode they might not consider it as option unless using Camel-k camel-karavan vscode extension. This makes Spring XML a sort of "low code" choice which can be easier for people less familiar with programming to use.

Low code

Camel integrations defined in XML, YAML or Groovy have this interesting feature where you can just deploy the xml or yaml configuration to camel-K or something like Apache Karaf and just run the integration. This can drastically simplify process of writing integrations in many ways.

Upvotes: 2

Related Questions