-3

The Camel Java DSL provides type-safety, code completion and proper support for refactoring. It also helps to modularize and (unit-)test your code in a great manner.

Speaking for the Camel XML syntax I only see the advantage of being able to modify and reload routes at runtime (e.g. via hawtio).

Obviously I'm really missing something here - so what is the rationale behind the use of Camel XML routes today?

gtonic
  • 2,295
  • 1
  • 24
  • 32
  • 1
    What makes you think there is one? The XML based configs were created first, why take them out if they work? Especially considering legacy applications. – Kayaman Sep 12 '16 at 20:07
  • I guess it still can be useful for xml-based Spring projects. XML configurations may be very handy (if you are using it carefully) in large projects. – vsminkov Sep 12 '16 at 20:10

3 Answers3

3
  1. In-Place editing of routes (although I would discourage doing that)
  2. quick&dirty one-off routes (e.g. routing from test to qa environment) or very simple projects - when you have a container like karaf or servicemix. No need to fire up your IDE/compile. Just write and drop to deploy folder.
  3. Maybe easier for non-developers

It is a matter of taste and preference.

ThomasW
  • 475
  • 3
  • 15
2

I have used both and I have to say the java dsl is far the easier and more powerful to use.

But the best approach is to combine them, especially if you are deploying to an OSGI environment like Karaf.

Use blueprint to define your beans and routeBuilder beans and bind them. The actual implementation is done in routeBuilder classes. In blueprint you can define properties and do a few other things as well, but the actual behavior of the routes is done in java.

Souciance Eqdam Rashti
  • 3,143
  • 3
  • 15
  • 31
1

First off, when you say XML do you mean Spring XML DSL or Blueprint XML DSL? While they do share most of their syntax, they are not identical. Blueprint XML DSL is the preferred way of defining Camel routes for an OSGi environment (i.e. Apache Karaf runtimes) while Spring XML DSL is nowadays more or less a legacy of the times when you could only use Spring through XML.

Having said that, I think it really boils down to personal preference - a lot of developers still prefer XML over Java for defining routes and find it easier to read and follow. I myself have always preferred the Java DSL since it's more flexible and powerful but I have to admit that XML provides better overview of the routes.

Miloš Milivojević
  • 5,219
  • 3
  • 26
  • 39