Hawtio 监控与管理 Apache Camel 路由 Router 可视化
相关文章:Serverless 实践落地,
前言
最近因项目需要,本人在调研 Apache Camel 相关技术。 我们期望能够使用一种灵活的方式,将 Camel 独立部署,不将业务代码耦合在 Camel 项目中。 去网上找了一下开源实现,目前只找到一个 Hawtio。
GitHub: 官方网站:
Camel 2.x + Hawtio Maven 插件部署示例
先到 Camel 官方下载页面下载 Camel 2.x
下载完成后解压,通过命令行进入到文件夹 examples/camel-example-spring 中,执行命令:
mvn compile io.hawt:hawtio-maven-plugin:2.9.1:spring
优点:
-
解耦,无须通过代码配置路由 路由可视化
缺点:
-
当配置发生错误时,会影响已有正常运行的路由 不便于加入自定义处理逻辑 Hawtio 更多的应该是作为监控,不适合修改逻辑
Camel 3.1.0 + SpringBoot 2.2.6 + Hawtio 2.9.1
引入依赖并配置
相关 Issue:
由于 Camel 3.1 默认关闭了 JMX,需要通过引入依赖 camel-management 打开,build.gradle 依赖部分示例:
dependencies { implementation org.springframework.boot:spring-boot-starter implementation org.springframework.boot:spring-boot-starter-actuator implementation org.apache.camel.springboot:camel-spring-boot-starter:3.1.0 implementation org.apache.camel:camel-management:3.1.0 implementation io.hawt:hawtio-springboot:2.9.1 testImplementation(org.springframework.boot:spring-boot-starter-test) { exclude group: org.junit.vintage, module: junit-vintage-engine } }
SpringBoot 项目配置 application.properties:
management.endpoints.web.exposure.include=hawtio,jolokia hawtio.authenticationEnabled=false
访问 Hawtio
项目启动后,可以访问 Hawtio 默认路径 /actuator/hawtio: 也可以启动一个 standalone Hawtio 应用程序,通过 JMX 连接运行 Camel 的应用(项目需要包含 Hawtio 相关依赖),下载地址:
java -jar hawtio-app-2.9.1.jar
添加完成之后,点击右侧 Connect 即可连接:
可视化效果: