dubbo service consumers

When using dubbo, a consumer is defined in the xml file, but this consumer is not used in the code. When I go online, I find that the process holding the consumer has not written the consumer URL to the registry, which is very confusing. Check the source code to get the answer, this is normal, in line with the working principle of dubbo

 

xml

    <dubbo:reference id="merchantShopService" interface="com.qbao.enterprise.api.service.MerchantShopService" version="1.0" />

 This service is not used in the code, such as autowired, applicationContext.get(XX) gets it

 

------------------------

Because the introduced remote service is not actually used, according to the working principle of dubbo, the refer remote service will trigger the write address to the registry only when the referenceService is used ==", so the URL of the consumer that is not used is not will be registered in the registry

 

dubbo:reference --> RefenceConfig --> get() Returns the interface implementation object used by the application layer. The bottom layer of this object is (proxy object, cluster, remoting), etc.

 

Fundamental:



 

 



 

 

 

 

 --------------------------------

ReferenceBean implements the FactoryBean interface. Only when getObject() is called (referenceService is used) will init be triggered, and the real refer process will be triggered, causing the consumer URL to be registered in the registry.

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327038506&siteId=291194637