# Issue 1:xml configuration for shutdown
## 1、Basic concepts
### Graceful Shutdown
Dubbo's native support for graceful downtime is based on the configured file 
named “dubbo.properties”. We added the value as follows:
> Dubbo.service.shutdown.wait=XX

that is to say, Dubbo stops receiving tasks, and waits for the completion of 
existing tasks, waiting for XX milleseconds.
### Configuration  
1) Properties Configuration "dubbo.properties":  it stores the configuration 
information shared by multiple containers and acts as a micro-registration 
center. It initialize the configuration through jvm.  
2) Xml configuration: we use the .xml to decouples the configuration of each 
component of dubbo. And bind with individual own configuration class and 
configuration tag, which is more friendly to the system development. See more 
details:
> Http://dubbo.apache.org/en/us/docs/user/references/xml/introduction.html

## 2. Solution
We configure the timeout for graceful shutdown in the xml file. For the tag 
named <dubbo:registry>, there is a parameter “wait”, 
![image](https://user-images.githubusercontent.com/18344620/44724670-f77ab380-ab05-11e8-9f3d-7018f0bab63a.png)
  
which denoted the timeout.

## 3. Implementation
![image](https://user-images.githubusercontent.com/18344620/44724688-07929300-ab06-11e8-8e70-34ee97620502.png)

Add a wait tag in the provider.xml.
## 4. Result
  
![image](https://user-images.githubusercontent.com/18344620/44724703-137e5500-ab06-11e8-8ac4-d3df9749c092.png)
![image](https://user-images.githubusercontent.com/18344620/44724711-1b3df980-ab06-11e8-9e54-7136bcb695b0.png)

# Issue 2: expose application for provider
## Problems
It is difficult for provider side to quickly locate which consumer's request 
has a problem. Thus the Dubbo needs to support application name in the url for 
better development experience.
## Solution
1)  Consumer
We define the application name in the “consumer.xml” 
![image](https://user-images.githubusercontent.com/18344620/44724728-285ae880-ab06-11e8-8734-a4676cf86bc8.png)

2)     RpcContext
RpcContext is a java class, defining a lot of parameters passed between the 
provider and consumer during the Remote Procedure Call. Thus we need to expand 
RpcContext.java to send the application name.
3)   ConsumerContextFilter
Before the consumer calls the remote service, we first call the invoke() method 
of the ConsumerContextFilter. And the method initializes the values of the RPC 
context information including the application name.
4)   Provider
The service provider can get the application name from the RpcContext.
## Implementation
### Solution 1. 
We tried two solutions when solving this problem. The first one is to add a new 
field “applicationName” to support the application name and two methods: 
setapplicationName() and getapplicationName() in RpcContext class. Then we add 
RpcContext. setapplicationName() in the invoke() of ComsumerContextFilter 
class. But when we use the getapplicationName() method to get the application 
information in the provider side, the value appears null. The protocol does not 
support the extension.
### Solution 2. 
After careful review, it is found that there is an attachments field in the 
RpcContext, which supports the developer to extend the field value in the form 
of a key-value. Details can be seen as follows: First, in the 
ConsumerContextFilter, we add the setAttachment() in invoke() method. The key 
is "Constants.APPLICATION_KEY" and the value can be extracted from the url.
 
![image](https://user-images.githubusercontent.com/18344620/44724745-37da3180-ab06-11e8-93b6-f17876e8ea5b.png)
## Result
 
![image](https://user-images.githubusercontent.com/18344620/44724758-3f013f80-ab06-11e8-9b82-f2d8dcabf099.png)
![image](https://user-images.githubusercontent.com/18344620/44724768-445e8a00-ab06-11e8-898b-55637b26b106.png)


# Issue 3: support register host
Dubbo has supported Providers to register their host to the registry server, 
and registry server can automatically get the IP by host name.  
Firstly:configure the host name of provider in the xml configuration file, the 
configuration is:  
![image](https://user-images.githubusercontent.com/18344620/44724783-52140f80-ab06-11e8-80d5-fffb25daecdb.png)

Secondly: In the ContextFilter, we add the NetUtil.getIpByHost method to map 
the host to Ip. You could try like this.
 
![image](https://user-images.githubusercontent.com/18344620/44724796-59d3b400-ab06-11e8-946e-895dbdf25e69.png)

## Result
 
![image](https://user-images.githubusercontent.com/18344620/44724803-5e986800-ab06-11e8-952c-c3ed610678d1.png)

[ Full content available at: 
https://github.com/apache/incubator-dubbo/issues/2397 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to