Dynamic Camel route configuration at deployment time: Java DSL or XML DSL?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic Camel route configuration at deployment time: Java DSL or XML DSL?

Gagnon, Joseph - 0553 - MITLL
Hello,

Let me preface this with the fact that I am still very new to Apache Camel. I'm still trying to understand how it all works, and what needs to be done (and HOW to do it) to achieve a particular effect.

I am trying to develop a Spring Boot application that will use Apache Camel to handle the transmission (and possibly also receipt) of data to/from a number of possible sources and destinations. The purpose of the application is to provide a means to produce/generate network traffic, at the network application level, that will be fed into another Spring Boot application - let's call this the target. We are trying to observe and measure the effects various network loads have on the target.

We would like to be able to transmit data via a number of protocols, including: ftp, http/s, file systems (nfs), various mail protocols (smtp, pop) and data streaming protocols for voice and video. There may be other protocols added at a later time. The data itself is irrelevant, we just need to be able to transmit data via various protocols with various loads.

These applications/services will be running in a containerized environment (Docker) that will be run within our local development and test environment, as well as possibly in a cloud environment, such as AWS. We have used Docker, Ansible, Terraform and are currently working towards using Kubernetes and Istio to manage the configuration, deployment, and operation of these applications.

We need to be able to provide specific configurations of Camel routes for particular deployments.

It would appear that the preferred method to configure Camel routes is via Java DSL, rather than XML DSL. The Camel documentation and nearly every other source of information I've found have a strong bias towards using Java DSL. Examples of XML DSL route configuration are far and few.

My initial impression is that going the Java DSL route (excuse the pun), would not work well with our need to be able to deploy a Camel application with a specific route configuration. It seems like you are required to have Java DSL defined route configurations hardwired into the code.

We think that it will be easier to provide a specific route configuration via an XML file that can be included in a deployment, hence why I've been trying to investigate and experiment with XML DSL. Perhaps we are mistaken in this regard.

My question to the community is: Considering what I've described above, can the Java DSL approach be used to meet the requirements as I've described them? Can we use Java DSL in a way that allows for dynamic route configuration? Keep in mind we would not be attempting to change configuration during operation, just in the course of performing a deployment.

If Java DSL could be used for this purpose, it would be very much appreciated if pointers to documentation, examples, etc. could be provided.

Note: I have also entered this question into StackOverflow at https://stackoverflow.com/questions/61014480/dynamic-camel-route-configuration-at-deployment-time-java-dsl-or-xml-dsl.

Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Camel route configuration at deployment time: Java DSL or XML DSL?

Claus Ibsen-2
Hi

I do think there are plenty of XML examples too, or if there is only
one such as Java, then the Camel DSL is easily 1:1 between Java and
XML so you should be able to figure out how to do it.

from -> <from>
to -> <to>
choice -> <choice>
aggregate -> <aggregate>

The difference is subtle when configuring some of these EIPs like the
splitter and aggregator as XML have a mix of attributes and xml tags.
And Java is ... java code.

For other examples where there are both Java and XML then the Camel in
Action book 2nd ed book, we made sure to include as many examples that
are in both Java and XML.
But for Spring Boot then Spring itself is moving to Java over the
Spring XML (eg spring <beans> XML) and as such many of the spring boot
examples are leaning towards Java.
But you can always mix, do Java code in spring boot and Camel routes
in XML or have both routes in Java and XML. However the latter is more
seldom.

For dynamic deployments, then you may also take a look at Camel K as
its all about this for cloud native and low-code integrations.


And as always we love contributions, so if there are some
documentations that lack XML examples then point them out, and if
possible also contribute back. The doc can be updated via github PRs
https://camel.apache.org/manual/latest/contributing.html

On Fri, Apr 3, 2020 at 5:00 PM Gagnon, Joseph - 0553 - MITLL
<[hidden email]> wrote:

>
> Hello,
>
> Let me preface this with the fact that I am still very new to Apache Camel. I'm still trying to understand how it all works, and what needs to be done (and HOW to do it) to achieve a particular effect.
>
> I am trying to develop a Spring Boot application that will use Apache Camel to handle the transmission (and possibly also receipt) of data to/from a number of possible sources and destinations. The purpose of the application is to provide a means to produce/generate network traffic, at the network application level, that will be fed into another Spring Boot application - let's call this the target. We are trying to observe and measure the effects various network loads have on the target.
>
> We would like to be able to transmit data via a number of protocols, including: ftp, http/s, file systems (nfs), various mail protocols (smtp, pop) and data streaming protocols for voice and video. There may be other protocols added at a later time. The data itself is irrelevant, we just need to be able to transmit data via various protocols with various loads.
>
> These applications/services will be running in a containerized environment (Docker) that will be run within our local development and test environment, as well as possibly in a cloud environment, such as AWS. We have used Docker, Ansible, Terraform and are currently working towards using Kubernetes and Istio to manage the configuration, deployment, and operation of these applications.
>
> We need to be able to provide specific configurations of Camel routes for particular deployments.
>
> It would appear that the preferred method to configure Camel routes is via Java DSL, rather than XML DSL. The Camel documentation and nearly every other source of information I've found have a strong bias towards using Java DSL. Examples of XML DSL route configuration are far and few.
>
> My initial impression is that going the Java DSL route (excuse the pun), would not work well with our need to be able to deploy a Camel application with a specific route configuration. It seems like you are required to have Java DSL defined route configurations hardwired into the code.
>
> We think that it will be easier to provide a specific route configuration via an XML file that can be included in a deployment, hence why I've been trying to investigate and experiment with XML DSL. Perhaps we are mistaken in this regard.
>
> My question to the community is: Considering what I've described above, can the Java DSL approach be used to meet the requirements as I've described them? Can we use Java DSL in a way that allows for dynamic route configuration? Keep in mind we would not be attempting to change configuration during operation, just in the course of performing a deployment.
>
> If Java DSL could be used for this purpose, it would be very much appreciated if pointers to documentation, examples, etc. could be provided.
>
> Note: I have also entered this question into StackOverflow at https://stackoverflow.com/questions/61014480/dynamic-camel-route-configuration-at-deployment-time-java-dsl-or-xml-dsl.
>


--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2