dubbo(provider,consumer) point-to-point direct connection configuration

1. Server interface configuration (providr sample) applicationContext-dubbo-smk.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
    xmlns="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans.xsd
 http://code.alibabatech.com/schema/dubbo
 http://code.alibabatech.com/schema/dubbo/dubbo.xsd" >

    <!-- Declare the service interface that needs to be exposed. When connecting directly, token=true should be removed, there will be unsafe factors, but direct connection is generally used for internal use, and security issues can be ignored for the time being -->
     <dubbo:service interface= "com.xxx.SmkService" ref="smkService" version="1.0"/>

</beans>

2. Server registration configuration:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=" http://www.springframework.org/schema/beans "
 xmlns:xsi=" http://www.w3.org /2001/XMLSchema-instance " xmlns:dubbo=" http://code.alibabatech.com/schema/dubbo "
 xsi:schemaLocation=" http://www.springframework.org/schema/beans
 http://www. springframework.org/schema/beans/spring-beans.xsd
 http://code.alibabatech.com/schema/dubbo
 http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">      
 <!-- Provided Side application information, used to calculate dependencies -->
 <dubbo:application name="xxcommon"></dubbo:application>
  <!-- The dubbo interface removes the registration center and uses a direct connection -->
    <dubbo:registry address="N/A" />
    <!-- Expose discovery service address using multicast broadcast registry -->
   <!-- <dubbo:registry address="multicast://xxx.5x.xx:1234?unicast=false" />-->
 <! --dubbo cluster development, please activate the following entry and log out of the multicast multicast -->
 <!--<dubbo:registry protocol="zookeeper" address="xx.xx.xx.xx:2181,xx.xx .xx.68:2181" />-->
 <!-- Expose service on port 20880 using dubbo protocol -->
 <dubbo:protocol name="dubbo" port="20880" ></dubbo:protocol>
<! -- <dubbo:service interface="com.xxDownloadService" version="1.0" ref="downloadService" />
 <dubbo:service interface="com.xx.UploadService" version="1.0" ref="uploadService" /> -->
</beans>

3.dubbo client configuration (consumer)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
    xmlns="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans.xsd
 http://code.alibabatech.com/schema/dubbo
 http://code.alibabatech.com/schema/dubbo/dubbo.xsd" >

    <!-- Consumer application name, used to calculate dependencies, not matching conditions, not the same as the provider -->

    <dubbo:application name="consumer-of-znmhcommon" />
    <!-- The dubbo interface removes the registry and uses a direct connection -->
  <!-- <dubbo:registry address="N/A" >< /dubbo:registry> --> 
    <!-- Expose discovery service address using multicast broadcast registry -->
   <!-- <dubbo:registry address="multicast://224.5.6.7:1234?unicast=false" / >-->
   <!--<dubbo:registry protocol="zookeeper" address="xx.xx.xx.xx:2181,xx.xx.xx.xx:2181" />-->
   
    <!-- generate Remote service proxy, which can be used like a local bean -->

    <dubbo:consumer timeout="30000" >
    </dubbo:consumer>
 <dubbo:reference
        id="demoService"
        interface="com.xx.DemoService"
        url="dubbo://127.0.0.1:20880/com.xx.DemoService"
        version="1.0" />
 
  <dubbo:reference
        id="smkService"
        interface="com.xx.SmkService"
        url="dubbo://xx:20880/com.xx.SmkService"
        version="1.0" />  
</beans>

 

http://blog.csdn.net/nauwzj/article/details/18708033

Guess you like

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