Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between NettyChannelBuilder and ManagedChannelBuilder

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?

like image 809
Shubham Sharma Avatar asked Oct 27 '25 09:10

Shubham Sharma


1 Answers

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.

like image 130
Eric Anderson Avatar answered Oct 30 '25 05:10

Eric Anderson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!