Taking the RPC Protocol Plugin
as an example, this section demonstrates how to use the SPI plugin provided by Dubbo to provide a custom RPC protocol implementation. If you want to understand how the SPI mechanism works and the list of built-in SPI extension points in the framework, please refer to the Reference Manual - SPI Extension.
Provide a Java class that implements the org.apache.dubbo.rpc.Protocol
interface.
Add a org.apache.dubbo.rpc.Protocol
file in the application’s resources/META-INF/services/
directory, and include the following configuration in the file:
resources/META-INF/services/org.apache.dubbo.rpc.Protocol
in this example.key=value
format, where key
can be defined arbitrarily, but it is recommended to add a specific prefix to avoid name collisions with Dubbo’s built-in implementations; value
must be the full path name of the implementation class.Modify the protocol configuration in the application to tell the Dubbo framework to use the custom protocol:
or
If you want to see more complete examples, please refer to other examples in this directory: