netty - How do I set up a camel netty4 component for synchronous request-reply? -
i need write camel component send synchronous request-reply on tcp legacy system. have tried set netty4 component, there weird happening. here route:
from("direct:foo") .dotry() .process(exchange -> { message message = (message) exchange.getin().getbody(); logger.info("sending message: {}", message); }) .tof("netty4:tcp://localhost:%d?sync=true&synchronous=true&requesttimeout=%d&encoders=stubencoder&decoders=stubencoder", port, timeout) .process(exchange -> { response response = (response) exchange.getin().getbody(); logger.info("[{}] received reply: {}", exchange, response); }) .enddotry() .docatch(readtimeoutexception.class) .process(exchange -> { // handle timeout... }) .end();
the remote port , timeout injected properties. input/output of route domain objects rest of application. have set codec translates these domain objects simple pipe-delimited string protocol sent remote server. have stub program simulate legacy host, listens on server socket, , sends response on client socket. stub works fine if connect test program.
what see happening route receives incoming message, calls codec encode message, , waits until hits timeout, goes timeout processor in catch block. in stub, see connection being made, , message received after timeout. stub sends response, it's late - route has moved on processing timeout. thought synchronous=true option make netty4 send , wait, doesn't seem happening. there other option i'm missing?
Comments
Post a Comment