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/12/10 21:47:48 UTC
How to specify the UDP source port in dynamic To (toD)?
I'm using *Camel 2.16.0*, *camel-netty4*, and the new dynamic *toD()* feature
to send UDP acknowledgements back to the associated UDP client.
In my Camel route that deals with acknowledgements, I have an
*AckBackProcessor* that composes the UDP response to be sent back to the UDP
client. Right before returning from the *AckBackProcessor* I print out the
*NETTY_LOCAL_ADDRESS* and *NETTY_REMOTE_ADDRESS* headers in the Exchange's
inMsg and they look as expected.
I'm required to use an application-specific well-known UDP source port in
the acknowledgement (e.g. *61133*). However, somehow, after the
*AckBackProcessor* returns and the *toD()* executes, my tcpdump shows that
the UDP source port has changed from *61133* to what looks to be an
ephemeral source port.
So my question is, with *camel-netty4* and the new dynamic *toD()* feature,
how do I specify a UDP source port of my choosing?
Here's what my route looks like. It's a SEDA queue:
from(ackQueueURI)
.setExchangePattern(ExchangePattern.InOnly)
.id("setExchangePattern_" + ackQueueRouteId)
.routeId(ackQueueRouteId)
.startupOrder(ackQueueRouteStartupOrder)
.setProperty(Exchange.CHARSET_NAME,
ExpressionBuilder.constantExpression(charsetName))
.id("setProperty_" + ackQueueRouteId + "_" + charsetName)
// AckBackProcessor formulates the UDP ack and does
setHeader("ACK_REQUIRED") to "true" or "false"
.process(ackBackProcessor).id(ackBackProcessorId)
.choice()
.when(header("ACK_REQUIRED").isEqualTo("false"))
.to("log:DEV_NULL_LOG?level=OFF") // Drop UDP packet since ack is not
required
.otherwise()
// Otherwise, this UDP request requires an acknowledgement.
// Dynamic To does remote address substitution from the in-flight
exchange header.
.toD(ackToURI).id("toD_" + ackQueueRouteId + "_TO_CLIENT")
.end();
Here's the method used to create the acknowledgement URI referenced within
the *toD(*):
/**
* Builds and returns the string containing the acknowledgment to URI.
*
* @param dest
* @param clientPipelineFactoryName
* @return The string containing the ackToURI
*/
private String getAckToURI(Destination dest, String
clientPipelineFactoryName) {
StringBuilder sb = new StringBuilder();
sb.append("netty4:udp").append(":/${header.CamelNettyRemoteAddress}")
.append("?clientPipelineFactory=#").append(clientPipelineFactoryName);
String ackOptions = dest.getOptions();
if(ackOptions != null && !ackOptions.isEmpty()) {
sb.append(ackOptions);
}
String ackExtraOptions = dest.getExtraOptions();
if(ackExtraOptions != null && !ackExtraOptions.isEmpty()) {
sb.append(ackExtraOptions);
}
logger.info("getAckToURI(): ackToURI = {}", sb.toString());
return sb.toString();
}
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-specify-the-UDP-source-port-in-dynamic-To-toD-tp5774964.html
Sent from the Camel - Users mailing list archive at Nabble.com.