Dubbo Service Configuration

Source: Internet
Author: User
Tags bind zookeeper
, Dubbo Registration Center Configuration
1.1 Dubbo.properties Way
If it is a stand-alone zookeeper service, you can configure Dubbo.registry.address=zookeeper://ip:port to tell Dubbo to use zookeeper to implement the registry, And the address of zookeeper is ip:port.
If the zookeeper is a cluster, the configuration parameters are the same, but the values of the parameters are slightly different, the corresponding parameters should be configured as DUBBO.REGISTRY.ADDRESS=ZOOKEEPER://IP0:PORT0?BACKUP=IP1: Port1, Ip2:port2,...., ipi:porti,..., ipn:portn.
1.2 Spring container XML Management method
The difference is that the above is configured with the properties to configure only one registry, but through XML configuration can be configured to configure multiple registries, and you can bind a service to which registry, if more than one registry, in the XML multi-configuration a <dubbo:registry /> tags, and you need to bind different id attribute values for differentiation. Other parameters in this way are similarly configured, meaning spring XML, which must be the XML that the spring container can load, otherwise Dubbo is unknown
1.3 The parameters he used
Dubbo Service Provider Configuration
2.1 Spring XML to expose the service
<dubbo:protocol name= "Dubbo" port= "20884" server= "Netty"/> is configured with a Dubbo protocol, the service port is 20884, and is using Netty as the server to communicate, There are Mina besides Netty. Dubbo supports other protocols such as WebService, HTTP, RMI, etc., in addition to supporting the Dubbo protocol
2.2 Properties Configuration Service Publishing
Dubbo Service Consumer Configuration
3.1 Synchronizing a subscription to a remote service
3.1.1 Your application is the consumer and the provider, and the registry is configured on the configuration provider, you do not have to configure it again. The registry that is configured here needs to be aware that the consumer's registry needs and publishes the same registry as the provider of the corresponding service, otherwise it cannot discover the required service information. The preferred configuration of the consumer is to add the Dubbo Reference service-related configuration in the spring XML, configured as follows: <dubbo:reference id= "Demoservice" interface= " Com.alibaba.dubbo.demo.DemoService "check=" false "/> Then simply inject the demoservice into the corresponding bean. You can inject remote services into a bean in the following configuration
<bean class= "com.alibaba.dubbo.demo.consumer.DemoAction" init-method= "Start" >
<property name= "Demoservice" ref= "Demoservice"/>
</bean>
3.2 Asynchronous invocation service mode one
<dubbo:reference id= "Demoservice" interface= "Com.alibaba.dubbo.demo.DemoService" check= "false" async= "true"/ >


3.3 Asynchronous invocation Service mode two
<dubbo:reference id= "Demoservice" interface= "Com.alibaba.dubbo.demo.DemoService" check= "false" >
<dubbo:method name= "SayHello" async= "true"/>
</dubbo:reference>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.