You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by SteveR <sr...@vonage.com> on 2015/08/03 16:38:47 UTC
Please help critique my route ...
I want to get better at Camel route design and would welcome any thoughts on
the below.
Thanks, Steve
Here's what I need to implement:
- *FROM:* receive UDP datagrams in ISO-8859-1 format. For this I use the
camel-netty component.
- *ACK:* Each received UDP datagram must be acknowledged by extracting a
cookie from the received datagram
and formulating the ACK using this cookie. For this function, I have an
AckBackProcessor that
implements org.apache.camel.Processor.
To sent the acknowledgement, the AckBackProcessor is basically doing:
exchange.getOut().setBody(ackBack.toString());
exchange.getOut().setHeaders(exchange.getIn().getHeaders()); // Copy
headers from IN to OUT to propagate them.
-* TO:* Each received datagram must be optionally forwarded (i.e. mirrored)
to a secondary remote host via UDP.
For this function, I'm currently using the EIP WireTap pattern with a
destination of netty:udp://host:port etc.
Maybe I should be using SEDA, not sure?
- *TO: *Log each received UDP datagram to a local backup file using the
Camel log component and the underlying
SLF4J/Log4j2 logging system.
- *TO:* Log each received UDP datagram to the local file system for
throughput logging using the Camel log component
and the underlying SLF4J/Log4j2 logging system. This is for the Camel
Throughput logger capability.
- *TO:* Implement the Camel DeadLetterChannel (use original message), with
the DLC queue being the local
file system, and using the underlying SLF4J/Log4j2 logging system.
- *TO:* Wrap each received UDP datagram in a custom JSON wrapper and send to
a Kafka topic using a synchronous producer.
I use the camel-kafka component for this and I have an KafkaProcessor that
implements org.apache.camel.Processor.
This processor handles the Kafka partitioning. I have another
PayloadWrapperProcessor that adds the customn JSON wrapper.
Here's basically what my route looks like. Just want to be sure I'm on the
right track. Any feedback and/or
improvements is greatly appreciated!!!
from(fromURI)
.routeId(sourceRouteId)
.startupOrder(routeStartupOrder)
.setProperty(Exchange.CHARSET_NAME,
ExpressionBuilder.constantExpression("ISO-8859-1"))
.wireTap(mirrorToURI)
.id(sourceRouteId + "_MIRROR")
.to(firstToURIs) // to(backupFileToURI, throughputFileToURI, sedaMainURI)
.id(sourceRouteId + "_TO_FIRST_URIS");
// ---------------------------------------------------------------
// The second route (i.e. sedaMainURI --> secondToURI) has a route
// scoped error handler. It’s a Dead Letter Channel that will
// send failed messages to a log for subsequent re-processing.
// ---------------------------------------------------------------
from(sedaMainURI)
.routeId(sedaMainRouteId)
// -----------------------------------------------------
// Add the route-scoped DeadLetterChannel error handler.
// -----------------------------------------------------
.errorHandler(deadLetterChannelBuilder)
.threads(threadPoolSize /*poolSize*/, threadPoolSize * 2 /*maxPoolSize*/)
.threadName("threads_" + sedaMainRouteId)
.callerRunsWhenRejected(true) // Hard-coded since we always want this
behavior!
// ------------------------------------------------------
// This processor adds an MPLR header along with the
// received exchange body and converts to wrapper format.
// ------------------------------------------------------
.process(payloadWrapperProcessor)
.id(payloadWrapperProcessorId)
// ------------------------------------------------
// This processor handles Kafka related processing.
// For example, determining the Kafka partitioning.
// ------------------------------------------------
.process(kafkaProcessor)
.id(kafkaProcessorId)
// ---------------------------------------------------
// Here we route to the final destination (e.g. Kafka)
// ---------------------------------------------------
.to(secondToURI)
--
View this message in context: http://camel.465427.n5.nabble.com/Please-help-critique-my-route-tp5770248.html
Sent from the Camel - Users mailing list archive at Nabble.com.