I am trying to understand the difference between ManagedChannelBuilder and NettyChannelBuilder. I came across this question but it only mentions details related to TLS configurations. Can someone explain the basic difference between the two?
According to the NettyChannelBuilder documentation, it uses Netty transport. What transport medium does the ManagedChannelBuilder use?
ManagedChannelBuilder is an abstract class and there are concrete implementations like NettyChannelBuilder and OkHttpChannelBuilder. When you use an API like ManagedChannelBuilder.forTarget() or Grpc.newChannelBuilder() gRPC finds an appropriate concrete implementation based on your platform and returns it (normally OkHttp on Android; Netty otherwise).
The OkHttpChannelBuilder and NettyChannelBuilder APIs have more configuration options, but have no guaranteed API stability. This is because they expose options specific to the implementation and if the implementation changes (e.g., from Netty 4 to Netty 5) they may need to be changed or replaced. Because of this, you should prefer using ManagedChannelBuilder when able.
There are also concrete implementations that won't be returned by ManagedChannelBuilder.forTarget(), like InProcessChannelBuilder, CronetChannelBuilder, and AndroidChannelBuilder. These are more specialized, either not "general purpose" or require additional configuration to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With