概述
dubbo-spring-boot-actuator 提供 Production-Ready 特性:
健康检查
控制断点
外部化配置
GitHub https://github.com/apache/incubator-dubbo-spring-boot-project/tree/master/dubbo-spring-boot-actuator#health-checks
版本
目前,dubbo-spring-boot-actuator将支持Spring Boot 2.x和1.x两个版本:
0.2.x是Spring Boot 2.x的主流发行版
0.1.x是用于维护Spring Boot 1.x的旧版本
与Maven整合
您可以通过向pom.xml添加以下依赖项,将最新的dubbo-spring-boot-actuator引入到您的项目中,
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-actuator</artifactId>
<version>0.2.0</version>
</dependency>
还依赖
<!-- dubbo actuator 依赖spring boot actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
如果您的项目无法解决依赖关系,请尝试添加以下存储库:
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
健康检查
dubbo-spring-boot-actuator支持标准的Spring Boot健康指示器作为生产就绪特性,它将聚合到Spring Boot的健康中,并在运行MVC (Spring Web MVC)和JMX (Java管理扩展)的HealthEndpoint上导出(如果它们都可用的话)。
Web端点:/health
假设Spring Boot Web应用程序未指定management.server.port,您可以通过Web Client访问http://localhost:8080/actuator/health,你可以可以专门为访问端点设置端口号,通过management.server.port设置。获得JSON格式的响应,如下所示:
{
"status": "UP",
"dubbo": {
"status": "UP",
"memory": {
"source": "management.health.dubbo.status.defaults",
"status": {
"level": "OK",
"message": "max:3641M,total:383M,used:92M,free:291M",
"description": null
}
},
"load": {
"source": "management.health.dubbo.status.extras",
"status": {
"level": "OK",
"message": "load:1.73583984375,cpu:8",
"description": null
}
},
"threadpool": {
"source": "management.health.dubbo.status.extras",
"status": {
"level": "OK",
"message": "Pool status:OK, max:200, core:200, largest:0, active:0, task:0, service port: 12345",
"description": null
}
},
"server": {
"source": "dubbo@ProtocolConfig.getStatus()",
"status": {
"level": "OK",
"message": "/192.168.1.103:12345(clients:0)",
"description": null
}
}
}
// ignore others
}
在上面的例子中,内存,负载,线程池和服务器是Dubbo的内置StatusCheckers。 Dubbo允许应用程序扩展StatusChecker的SPI。
默认,内存和负载将添加到Dubbo的HealthIndicator中,它可以被外部化配置StatusChecker的默认值覆盖。
JMX端点:健康
Health是一个JMX (Java管理扩展)端点,具有ObjectName org.springframework.boot:type=Endpoint,name=Health,它可以由JMX代理管理,例如。JDK工具:jconsole等等。
内置StatusCheckers
META-INF /dubbo/internal/com.alibaba.dubbo.common.status.StatusChecker声明内置StatusCheckers如下:
memory=com.alibaba.dubbo.common.status.support.MemoryStatusChecker
load=com.alibaba.dubbo.common.status.support.LoadStatusChecker
spring=com.alibaba.dubbo.config.spring.status.SpringStatusChecker
datasource=com.alibaba.dubbo.config.spring.status.DataSourceStatusChecker
server=com.alibaba.dubbo.rpc.protocol.dubbo.status.ServerStatusChecker
threadpool=com.alibaba.dubbo.rpc.protocol.dubbo.status.ThreadPoolStatusChecker
registry=com.alibaba.dubbo.registry.status.RegistryStatusChecker
作为StatusChecker名称的属性键可以是外部化配置中的management.health.dubbo.status.*的有效值。
端点
Actuator端点dubbo支持Actuator端点:
ID | Enabled | HTTP URI | HTTP Method | Description | Content Type |
---|---|---|---|---|---|
dubbo | true | /actuator/dubbo | GET | Exposes Dubbo's meta data | application/json |
dubbo-properties | true | /actuator/dubbo/properties | GET | Exposes all Dubbo's Properties | application/json |
dubbo-services | false | /dubbo/services | GET | Exposes all Dubbo's ServiceBean | application/json |
dubbo-references | false | /actuator/dubbo/references | GET | Exposes all Dubbo's ReferenceBean | application/json |
dubbo-configs | true | /actuator/dubbo/configs | GET | Exposes all Dubbo's *Config | application/json |
dubbo-shutdown | false | /actuator/dubbo/shutdown | POST | Shutdown Dubbo services | application/json |
# Dubbo Endpoints Default Properties is loaded by @PropertySource with low order,
# those values of properties can be override by higher PropertySource
# @see DubboEndpointsAutoConfiguration
# Set enabled for Dubbo Endpoints
management.endpoint.dubbo.enabled = true
management.endpoint.dubbo-shutdown.enabled = false
management.endpoint.dubbo-configs.enabled = true
management.endpoint.dubbo-services.enabled = false
management.endpoint.dubbo-references.enabled = false
management.endpoint.dubbo-properties.enabled = true
# "management.endpoints.web.base-path" should not be configured in this file
# Re-defines path-mapping of Dubbo Web Endpoints
management.endpoints.web.path-mapping.dubbo-shutdown = dubbo/shutdown
management.endpoints.web.path-mapping.dubbo-configs = dubbo/configs
management.endpoints.web.path-mapping.dubbo-services = dubbo/services
management.endpoints.web.path-mapping.dubbo-references = dubbo/references
management.endpoints.web.path-mapping.dubbo-properties = dubbo/properties
Web端点
/actuator/dubbo
/dubbo暴露了Dubbo的元数据:
{
"timestamp": 1516623290166,
"versions": {
"dubbo-spring-boot": "0.2.0"
"dubbo": "2.6.2"
},
"urls": {
"dubbo": "https://github.com/alibaba/dubbo",
"google-group": "http://groups.google.com/group/dubbo",
"github": "https://github.com/dubbo/dubbo-spring-boot-project",
"issues": "https://github.com/dubbo/dubbo-spring-boot-project/issues",
"git": "https://github.com/dubbo/dubbo-spring-boot-project.git"
}
}
/actuator/dubbo/properties
/actuator/dubbo/properties从Spring Boot外化配置(a.k.a PropertySources)公开所有Dubbo的属性:
{
"dubbo.application.id": "dubbo-provider-demo",
"dubbo.application.name": "dubbo-provider-demo",
"dubbo.application.qos-enable": "false",
"dubbo.application.qos-port": "33333",
"dubbo.protocol.id": "dubbo",
"dubbo.protocol.name": "dubbo",
"dubbo.protocol.port": "12345",
"dubbo.registry.address": "N/A",
"dubbo.registry.id": "my-registry",
"dubbo.scan.basePackages": "com.alibaba.boot.dubbo.demo.provider.service"
}
JSON的结构是简单的Key-Value格式,键是属性名称,值是属性值。
/actuator/dubbo/services
/actuator/dubbo/services公开在Spring ApplicationContext中通过<dubbo:service />或@Service声明的所有Dubbo的ServiceBean
{
"ServiceBean@com.alibaba.boot.dubbo.demo.api.DemoService#defaultDemoService": {
"accesslog": null,
"actives": null,
"cache": null,
"callbacks": null,
"class": "com.alibaba.dubbo.config.spring.ServiceBean",
"cluster": null,
"connections": null,
"delay": null,
"document": null,
"executes": null,
"export": null,
"exported": true,
"filter": "",
"generic": "false",
"group": null,
"id": "com.alibaba.boot.dubbo.demo.api.DemoService",
"interface": "com.alibaba.boot.dubbo.demo.api.DemoService",
"interfaceClass": "com.alibaba.boot.dubbo.demo.api.DemoService",
"layer": null,
"listener": "",
"loadbalance": null,
"local": null,
"merger": null,
"mock": null,
"onconnect": null,
"ondisconnect": null,
"owner": null,
"path": "com.alibaba.boot.dubbo.demo.api.DemoService",
"proxy": null,
"retries": null,
"scope": null,
"sent": null,
"stub": null,
"timeout": null,
"token": null,
"unexported": false,
"uniqueServiceName": "com.alibaba.boot.dubbo.demo.api.DemoService:1.0.0",
"validation": null,
"version": "1.0.0",
"warmup": null,
"weight": null,
"serviceClass": "com.alibaba.boot.dubbo.demo.provider.service.DefaultDemoService"
}
}
关键是ServiceBean的Bean名称,ServiceBean的属性组成值。
/actuator/dubbo/references
/actuator/dubbo/references公开所有通过@Reference on Field或Method声明的Dubbo的ReferenceBean:
{
"private com.alibaba.boot.dubbo.demo.api.DemoService com.alibaba.boot.dubbo.demo.consumer.controller.DemoConsumerController.demoService": {
"actives": null,
"cache": null,
"callbacks": null,
"class": "com.alibaba.dubbo.config.spring.ReferenceBean",
"client": null,
"cluster": null,
"connections": null,
"filter": "",
"generic": null,
"group": null,
"id": "com.alibaba.boot.dubbo.demo.api.DemoService",
"interface": "com.alibaba.boot.dubbo.demo.api.DemoService",
"interfaceClass": "com.alibaba.boot.dubbo.demo.api.DemoService",
"layer": null,
"lazy": null,
"listener": "",
"loadbalance": null,
"local": null,
"merger": null,
"mock": null,
"objectType": "com.alibaba.boot.dubbo.demo.api.DemoService",
"onconnect": null,
"ondisconnect": null,
"owner": null,
"protocol": null,
"proxy": null,
"reconnect": null,
"retries": null,
"scope": null,
"sent": null,
"singleton": true,
"sticky": null,
"stub": null,
"stubevent": null,
"timeout": null,
"uniqueServiceName": "com.alibaba.boot.dubbo.demo.api.DemoService:1.0.0",
"url": "dubbo://localhost:12345",
"validation": null,
"version": "1.0.0",
"invoker": {
"class": "com.alibaba.dubbo.common.bytecode.proxy0"
}
}
}
关键是@Reference Field或Method的字符串表示,ReferenceBean的属性组成值。
/actuator/dubbo/configs
actuator / dubbo / configs暴露所有Dubbo的* Config:
{
"ApplicationConfig": {
"dubbo-consumer-demo": {
"architecture": null,
"class": "com.alibaba.dubbo.config.ApplicationConfig",
"compiler": null,
"dumpDirectory": null,
"environment": null,
"id": "dubbo-consumer-demo",
"logger": null,
"name": "dubbo-consumer-demo",
"organization": null,
"owner": null,
"version": null
}
},
"ConsumerConfig": {
},
"MethodConfig": {
},
"ModuleConfig": {
},
"MonitorConfig": {
},
"ProtocolConfig": {
"dubbo": {
"accepts": null,
"accesslog": null,
"buffer": null,
"charset": null,
"class": "com.alibaba.dubbo.config.ProtocolConfig",
"client": null,
"codec": null,
"contextpath": null,
"dispatcher": null,
"dispather": null,
"exchanger": null,
"heartbeat": null,
"host": null,
"id": "dubbo",
"iothreads": null,
"name": "dubbo",
"networker": null,
"path": null,
"payload": null,
"port": 12345,
"prompt": null,
"queues": null,
"serialization": null,
"server": null,
"status": null,
"telnet": null,
"threadpool": null,
"threads": null,
"transporter": null
}
},
"ProviderConfig": {
},
"ReferenceConfig": {
},
"RegistryConfig": {
},
"ServiceConfig": {
}
}
关键是Dubbo *Config类的简单名称,值是*Config bean的名称属性映射。
/actuator/dubbo/shutdown
/ actuator / dubbo / shutdown关闭Dubbo的组件,包括注册表,协议,服务和引用:
{
"shutdown.count": {
"registries": 0,
"protocols": 1,
"services": 0,
"references": 1
}
}
“shutdown.count”表示Dubbo组件的关闭计数,该值表示已关闭的组件数。
外部化配置
默认的StatusChecker
management.health.dubbo.status.defaults是用于设置StatusCheckers名称的属性名称,其值允许为多个值,例如
management.health.dubbo.status.defaults = registry,memory,load
默认值
默认值是
management.health.dubbo.status.defaults = memory,load
StatusChecker额外功能
management.health.dubbo.status.extras用于覆盖[StatusChecker的默认值],多个值由逗号分隔:
management.health.dubbo.status.extras = load,threadpool
健康检查已启用
management.health.dubbo.enabled是一个启用配置来打开或关闭运行状况检查功能,其默认值为true。
如果您要禁用运行状况检查,则应将management.health.dubbo.enabled应用于false:
management.health.dubbo.enabled = false
端点启用
Dubbo Spring Boot提供执行器端点,但其中一些是禁用的。 如果您要启用它们,请将以下属性添加到外部配置中:
# Enables Dubbo All Endpoints
management.endpoint.dubbo.enabled = true
management.endpoint.dubbo-shutdown.enabled = true
management.endpoint.dubbo-configs.enabled = true
management.endpoint.dubbo-services.enabled = true
management.endpoint.dubbo-references.enabled = true
management.endpoint.dubbo-properties.enabled = true
源码地址:https://gitee.com/niugangxy/dubbo
微信公众号
最后
以上就是标致薯片为你收集整理的4.Dubbo之dubbo-spring-boot-actuator版本与Maven整合健康检查的全部内容,希望文章能够帮你解决4.Dubbo之dubbo-spring-boot-actuator版本与Maven整合健康检查所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复