Camel - Designing scalable dynamic dataflow

184
May 03, 2018, at 06:00 AM

Use case: I receive a message from a source endpoint. Depending on the type of message, it gets handled by completely different business logic (e.g. http request, tcp message, db call). Afterwards, the outcome and passed downstream (assume uniform standard for output message)

The route would look something like this:

from(_source_)
...
// handle data (this is dynamic)
...
process(_logger_)
to(_receiver_)

A straight forward solution would be use choice():

... // Upstream
.choice()
.when(someCondition).process(sendHTTP)
.when(anotherCondition).process(getToken).process(sendTCP)
.otherwise().process(sendToDB)
... // Downstream

But that's not very scalable.

Another solution would be to just put everything in a single processor which in turn calls a client that has polymorphic behaviour:

... // Upstream
.process(messageSwitch)
... // Downstream
public class MessageSwitch implements Processor {
    public void process(Exchange ex) {
         RequestClient client = this.resolveClient(ex);
         client.sendRequest(ex.getIn());
     }
}

However, this also makes us lose sight of the route. In that case, my question is whether or not it is common practice to execute a new route that takes place inside a processor. For example, I may want to execute a http call through the http4 library (http://camel.apache.org/http4.html).

Or maybe I am approaching this problem incorrectly.

Rent Charter Buses Company
READ ALSO
Java app in docker: Failed to get driver instance for postgres

Java app in docker: Failed to get driver instance for postgres

I created a java web appWhen I run java -jar xxx

274
Nested hash map with hash map

Nested hash map with hash map

i want to create a hashmap that return this output:

212
How to declare 2D Arrays in Java and Implement them (Procedural Programming)

How to declare 2D Arrays in Java and Implement them (Procedural Programming)

I'm struggling to understand 2D arrays and my exam is in 2 days, I've tried myself but I just can't get my head around it so this is basically my last resort and I really need help understanding them

178
Using the correct JDK or changing default in Netbeans on Linux OS

Using the correct JDK or changing default in Netbeans on Linux OS

Disclaimer: I am new to Java, new to Linux, and new to Netbeans - apologies for any over/under explanation - please ask and I will add/remove info

337