Dubbo configuration File Detailed

Source: Internet
Author: User

First, Dubbo Common configuration

<Dubbo:service/>service configuration, used to expose a service, define the meta-information of the service, a service can be exposed with multiple protocols, and a service can be registered to multiple registries. eg,<Dubbo:serviceref= "Demoservice"Interface= "Com.unj.dubbotest.provider.DemoService" /><dubbo:reference/>A reference service configuration that creates a remote service proxy that can point to multiple registries. eg,<dubbo:referenceID= "Demoservice"Interface= "Com.unj.dubbotest.provider.DemoService" /><Dubbo:protocol/>protocol configuration, which is used to configure the protocol information for the service provider, which is specified by the provider and passively accepted by the consumer. eg,<Dubbo:protocolname= "Dubbo"Port= "20880" /><dubbo:application/>app configuration, used to configure current app information, whether the app is a provider or a consumer. eg,<dubbo:applicationname= "Xixi_provider" />    <dubbo:applicationname= "Hehe_consumer" /><Dubbo:module/>module configuration for configuring the current module information, optional. <Dubbo:registry/>registry configuration for configuring connection registry related information. eg,<Dubbo:registryAddress= "zookeeper://192.168.2.249:2181" /><Dubbo:monitor/>Monitoring Center configuration for configuring connection monitoring Center related information, optional. <Dubbo:provider/>The default value of the provider, which is optional when the Protocolconfig and ServiceConfig properties are not configured. <Dubbo:consumer/>Consumer default configuration, this default value is optional when referenceconfig a property is not configured. <Dubbo:method/>method Configuration, which is used for serviceconfig and Referenceconfig to specify method-level configuration information. <dubbo:argument/>Used to specify the method parameter configuration.

Second, service call timeout setting

In the example of timeout, the configuration lookup order is shown, other retries, loadbalance, actives are similar.
Method-level precedence, interface rank, global configuration again.
If the level is the same, the consumer takes precedence and the provider second.

Where the service provider is configured to pass the URL through the registry to the consumer.
It is recommended that the service provider set a time-out because a method needs to be executed for how long, and the service provider knows that if a consumer references multiple services at the same time, it does not need to care about the timeout setting for each service.
In theory referenceconfig non-service identity configuration, in Consumerconfig,serviceconfig, Providerconfig can be configured by default.

third, start-up inspection
Dubbo the provincial capital at startup, check if dependent services are available, throw exceptions when not available, prevent spring initialization from completing so that problems can be detected early, and default check=true.

If your spring container is lazy-loaded, or if you defer referencing the service through API programming, turn off check, otherwise the service is temporarily unavailable, throws an exception, gets a null reference, and, if check=false, always returns a reference, which can be automatically connected when the service resumes.

The

can turn off the check by check= "false", for example, when testing, some services do not care, or there is a cyclic dependency, a party must start first.

  1, close the start-up check for a service: (No provider times wrong)  <  Span style= "color: #800000;" >dubbo:reference  interface  = " Com.foo.BarService "  check  =" false "   />   <  dubbo:consumer  check  = "false"  />   3, close check on registry startup: (Failed to register subscription error)  <  dubbo:registry  check  = "false"  />  

The reference defaults to deferred initialization, which is initialized only if the reference is injected into another bean or obtained by Getbean ().
If hunger loading is required, that is, no one is referenced and generates a dynamic agent immediately, you can configure:

<interface= "Com.foo.BarService"  init= "true"/>

Iv. Subscription
1. Questions
To facilitate development testing, it is often possible to share a registry of all services available online, at which point a service provider that is under development may have an impact on the consumer's inability to function properly.

2. Solutions
You can let the service provider developer, subscribe only to the service (the development of the service may depend on other services), instead of registering the service being developed, test the service being developed by direct connection.

To disable the enrollment configuration: <  address= "10.20.153.10:9090"  register= "false"/> or:  <address= "10.20.153.10:9090?register=false"/>

Five, ECHO test (test service is available)
The echo test is used to detect whether the service is available, and the Echo test executes in accordance with the normal request process and is able to test whether the entire call is unobstructed and can be monitored.
All services automatically implement the EchoService interface, and can be used only by forcing any service reference to EchoService.

eg,<id= "Memberservice"  interface= "Com.xxx.MemberService"  />memberservice memberservice = Ctx.getbean ("Memberservice");//Remote Service reference EchoService EchoService = (EchoService) Memberservice; Force transition to echoservicestring status = EchoService. $echo ("OK"); echo Test Availability assert (Status.equals ("OK"))

vi.. Delayed Connection
Delay connections, which are used to reduce the number of long connections, and then create long connections when there is a call to initiate.
Valid only for Dubbo protocols that use long connections.

<name= "Dubbo"  lazy= "true"/>

Seven, token authentication
Prevents consumers from bypassing the registry access provider, controlling permissions in the registry to decide whether to give the customer a license, the registry can flexibly change the authorization method without the need to modify or upgrade the provider

1. Global Settings Enable token authentication:<!--Random token token, generated using UUID -<Dubbo:providerInterface= "Com.foo.BarService"token= "true" /><!--fixed token token, equivalent to password -<Dubbo:providerInterface= "Com.foo.BarService"token= "123456" />2. Service level settings Enable token authentication:<!--Random token token, generated using UUID -<Dubbo:serviceInterface= "Com.foo.BarService"token= "true" /><!--fixed token token, equivalent to password -<Dubbo:serviceInterface= "Com.foo.BarService"token= "123456" />3. Protocol level setting enable token authentication:<!--Random token token, generated using UUID -<Dubbo:protocolname= "Dubbo"token= "true" /><!--fixed token token, equivalent to password -<Dubbo:protocolname= "Dubbo"token= "123456" />

Eight, log adaptation
Default Auto-find: log4j, slf4j, JCL, JDK

You can configure the log output policy in the following ways: Dubbo:application logger= "log4j"/>

Access log:
If you want to log every request, you can turn on the access log, similar to Apache's access log. This log volume is larger, please note the disk capacity.

Output the access log to the current app's log4j log:

<accesslog= "true"/>

To output the access log to the specified file:

<accesslog= "Http://10.20.160.198/wiki/display/dubbo/foo/bar.log"/> 

Ix. Configuring Dubbo Cache files

The configuration method is as follows:

< Dubbo:registryfile  />

Attention:
The path of the file, the application can be adjusted as needed to ensure that the file is not purged during the release process. If you have more than one application process, be careful not to use the same file to prevent content from being overwritten.

This file will be cached:
List of registries
List of service providers

With this configuration, when the Dubbo Registry is unavailable during the app restart, the app reads the service provider list from this cache file, further guaranteeing application reliability.

Dubbo configuration File Detailed

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.