Reputation: 122381
I am considering moving my Java NIO implementation over to JBoss Netty as it provides a much cleaner model than I have implemented. The implementation manages a number of client connections to components over TCP using a proprietary protocol.
One aspect of my implementation, that I cannot see in Netty, is the ability to set arbitrary timeouts, which:
ReadTimeoutHandler
but can the timeout value be changed/turned off easily by the Component as it moves through the state machine?Can this timeout mechanism be accomplished using Netty?
Conclusion: Given I would need to implement a timeout mechanism, which would run within the its own thread, I am not going to convert to using Netty after all.
Upvotes: 1
Views: 2809
Reputation: 7334
See ChannelConfig. The method setConnectTimeoutMillis(int) sets the timeout in milliseconds. You can invoke this method via a Bootstrap instance by calling setOption(String, Object). The name
would be "connectTimeoutMillis" and the value
would be the desired timeout in milliseconds.
The following snippet shows how to set the connect timeout to 5000 milliseconds (5 seconds).
ClientBootstrap bootstrap... // bootstrap instance
bootstrap.setOption("connectTimeoutMillis", 5000);
Upvotes: 3