This example shows how the multiple protocols on one port
works in Dubbo. We will
dubbo
and tri
protocol at the same time on one port.dubbo
and tri
protocol respectively.This example replies on Nacos as service discovery registry center, so you need to run the Nacos server first, there are two ways to do so:
Enter ‘dubbo-samples-multiple-protocols’ directory, run the following command:
$ mvn clean install
Enter provider directory:
$ cd dubbo-samples-multiple-protocols-provider
then, run the following command to start provider:
$ mvn compile exec:java -Dexec.mainClass="org.apache.dubbo.protocol.multiple.demo.provider.ProviderApplication"
Run the following command to see server works as expected:
curl \ --header "Content-Type: application/json" \ --data '["Dubbo"]' \ http://localhost:20880/org.apache.dubbo.protocol.multiple.demo.DemoService/sayHello
dubbo
consumerEnter dubbo
consumer directory:
$ cd dubbo-samples-multiple-protocols-dubbo-consumer
then, run the following command to start consumer:
$ mvn compile exec:java -Dexec.mainClass="org.apache.dubbo.protocol.multiple.demo.consumer.DubboConsumerApplication"
triple
consumerEnter triple
consumer directory:
$ cd dubbo-samples-multiple-protocols-triple-consumer
then, run the following command to start consumer:
$ mvn compile exec:java -Dexec.mainClass="org.apache.dubbo.protocol.multiple.demo.consumer.TripleConsumerApplication"