How does a dubbo consumer subscribe to a provider's services?
我想大声告诉你2017-05-17 10:05:25
0
4
730
After I write the service provider program, how do service consumers subscribe to their own services from the registration center? How do service consumers know what services I provide?
The provider registers the service to the registration center The consumer configures locally which services it depends on, and after going online, it goes to the registration center to retrieve the provider. After retrieval, the two are directly connected.
Service provider implements class A and annotates it @org.springframework.stereotype.Service @com.alibaba.dubbo.config.annotation.Service(protocol = {"dubbo"})
Serve consumers
<dubbo:reference id="Customize a name" interface="Interface B">
The configuration file required by both projects in the dubbo configuration file <dubbo:registry address="Your registration center" /> <dubbo:annotation package="Scan annotation package" /> < dubbo:protocol name="dubbo"></dubbo:protocol>
Consumers will go to the registration center to find the service interface they need. If the service exists, the address of the service interface will be returned. Then the consumer will use this address to call the service provider's interface. What should be noted here is that consumers do not immediately obtain services directly from the registration center, but only obtain the address.
The provider registers the service to the registration center
The consumer configures locally which services it depends on, and after going online, it goes to the registration center to retrieve the provider. After retrieval, the two are directly connected.
class A implements B
Service provider implements class A and annotates it
@org.springframework.stereotype.Service
@com.alibaba.dubbo.config.annotation.Service(protocol = {"dubbo"})
Serve consumers
<dubbo:reference id="Customize a name" interface="Interface B">
The configuration file required by both projects in the dubbo configuration file
<dubbo:registry address="Your registration center" />
<dubbo:annotation package="Scan annotation package" />
< dubbo:protocol name="dubbo"></dubbo:protocol>
How do service consumers know what services I provide?
Documentation, communication
Consumers will go to the registration center to find the service interface they need. If the service exists, the address of the service interface will be returned. Then the consumer will use this address to call the service provider's interface. What should be noted here is that consumers do not immediately obtain services directly from the registration center, but only obtain the address.