camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SteveR <>
Subject Camel netty: How to send UDP reply based on NETTY_REMOTE_ADDRESS?
Date Sun, 25 Oct 2015 02:50:00 GMT

I have a Linux RedHat-6 application using *Camel 2.15.2* and *netty3* and I
need to reply to various UDP clients that send UDP requests into my Camel
route.  However, I can't do a blind-ACK. That is, I have to first process
each received UDP request, synchronously produce it to a remote Kafka
cluster, and only when the Exchange is successfully produced to Kafka, then
formulate the associated UDP reply and send it back to the associated UDP

To do this my input route consumes via *netty:udp* on a well-known listen
port, and I then place all received exchanges on a *SEDA_KAFKA_QUEUE* that
consumes them and produces to Kafka.  I'm using the Camel
*onCompletion.onCompleteOnly()* mechanism in this Kafka route to trigger
sending the successfully processed Exchanges to a *SEDA_UDP_ACK_QUEUE* that
will use a processor to formulate the ACK body and then send it as the UDP
reply via the Camel netty component.

I can only get this to work and actually send the ACK if I use a hard-coded
port number in the netty URI. But in production, I'll be receiving from many
different UDP clients and I need to send back to their ephemeral port
number.  I'm looking for a way to parameterize the sending of the UDP
replies back using the *host:port* combo that is specified in the
*CamelNettyRemoteAddress* header of the Exchange.

Any thoughts greatly appreciated.  Below are my routes.

  Thanks, SteveR

			.threads(threadPoolSize /*poolSize*/, threadPoolSize * 2
/*maxPoolSize*/).threadName("threads_" + sourceRouteId);
			.to(kafkaQueueURI).id(sourceRouteId + "_TO_KAFKA_QUEUE");

		// ------------------------
		// ------------------------
			.errorHandler(deadLetterChannelBuilder) // Add route-scoped
DeadLetterChannel error handler
				.onCompleteOnly()     // Synchronize only after Exchange completes
successfully with no errors
				.parallelProcessing() // Tells Camel to use a thread pool for
onCompletion route
				.to(ackQueueURI).id(sourceRouteId + "_ON_COMPLETION_ONLY_TO_ACK_QUEUE")
			.end() // Must use end() to denote the end of the onCompletion route
			.threads(threadPoolSize /*poolSize*/, threadPoolSize * 2
/*maxPoolSize*/).threadName("threads_" + kafkaQueueRouteId)
			// ------------------------------------------------
			// This processor handles Kafka related processing.
			// For example, determining the Kafka partitioning.
			// ------------------------------------------------
			// ---------------------------------------------------
			// Here we route to the final destination (e.g. Kafka)
			// ---------------------------------------------------

		// ----------------------------
		// ----------------------------

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message