in netty-custom-correlation/src/main/java/org/apache/camel/example/netty/MyClient.java [87:110]
public void configure() throws Exception {
// lets build a special custom error message for timeout
onException(ExchangeTimedOutException.class)
// here we tell Camel to continue routing
.continued(true)
// after it has built this special timeout error message body
.setBody(simple("#${header.corId}:${header.word}-Time out error!!!"));
from("timer:trigger").id("client")
// set correlation id as unique incrementing number
.setHeader("corId", method(this, "increment"))
// set random word to use in request
.setHeader("word", method(this, "word"))
// build request message as a string body
.setBody(simple("#${header.corId}:${header.word}"))
// log request before
.log("Request: ${id}:${body}")
// call netty server using a single shared connection and using custom correlation manager
// to ensure we can correctly map the request and response pairs
.to("netty:tcp://localhost:4444?sync=true&encoders=#bean:myEncoder&decoders=#bean:myDecoder"
+ "&producerPoolEnabled=false&correlationManager=#bean:myManager")
// log response after
.log("Response: ${id}:${body}");
}