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.
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I created a java web appWhen I run java -jar xxx
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
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