第 4 章 对 Camel 的调试支持
Apache Camel 的 VS Code 扩展被列为开发支持。有关 开发支持范围的更多信息,请参阅 红帽构建的 Apache Camel 开发支持覆盖范围。
4.1. 关于 Apache Camel 路由的 Debug Adapter 复制链接链接已复制到粘贴板!
VS Code Debug Adapter 是一个 Visual Studio Code 扩展,您可以使用它调试以 Java、Yaml 或 XML DSL 编写的运行 Camel 路由。
4.1.1. 调试适配器的功能 复制链接链接已复制到粘贴板!
用于 Apache Camel 的 VS Code Debug Adapter 支持以下功能:
- 仅用于 XML 的 Camel Main 模式。
- 使用 Camel debugger,使用 JMX url 将其附加到以 Java、Yaml 或 XML 编写的正在运行的 Camel 路由。
- Camel 调试器的本地使用,使用 PID 将其附加到以 Java、Yaml 或 XML 编写的正在运行的 Camel 路由中。
- 您可以将它用于单个 Camel 上下文。
- 添加或删除断点。
- 使用简单语言的条件断点。
- 检查暂停断点上的变量值.
- 恢复单个路由实例,并恢复所有路由实例。
- 当路由定义位于同一文件中时的步骤。
- 允许在消息正文中更新 scope Debugger 中的变量,在消息标题中,类型为 String,以及 String 类型的交换属性
支持命令
Run Camel Application with JBang 和 Debug。此命令允许在简单情况下有一个点的 start 和 Camel debug。此命令通过以下方式提供:
- 命令的步骤.它需要当前编辑器中打开的有效 Camel 文件。
-
File explorer 中的上下文菜单.它对于所有 5.2.
xml、...javajava、....yaml和 5.2.yml可见。 -
在 Camel 文件的顶部对代码进行编码(lens 的高度特征是检查是否有 from 和 a to 或一个
java、xml和yaml文件中的日志)。
支持使用 JBang 命令运行 Camel 应用程序。- 它需要在一个编辑器中打开的 Yaml DSL (.yaml|.yml)中定义的有效 Camel 文件。
- Camel debugger 启动配置片断
- 配置片段以启动 Camel 应用程序准备好接受使用 JBang 的 Camel 调试器连接,或 Maven 与 Camel maven 插件
4.1.2. 要求 复制链接链接已复制到粘贴板!
在使用 VS Code Debug Adapter for Apache Camel 扩展时,必须考虑以下点:
先决条件
Java 运行时环境:
- 17 或更高版本
-
com.sun.tools.attach.VirtualMachineinstalled。
Camel 实例:
- Camel 版本 3.16 或更高版本
-
camel-debug在 classpath 中。 -
JMX启用。
对于某些功能,JBang 必须在 CLI 环境中可用。
4.1.3. 为 Apache Camel 安装 VS Code Debug Adapter 复制链接链接已复制到粘贴板!
您可以从 VS Code Extension Marketplace 和 Open VSX Registry 下载适用于 Apache Camel 的 VS Code Debug Adapter。您还可以直接在 Microsoft VS Code 中安装 Apache Camel 扩展的 Debug Adapter。
流程
- 打开 VS Code 编辑器。
- 在 VS Code 编辑器中,选择 View > Extensions。
- 在搜索栏中,键入 Camel Debug。从搜索结果中选择 Debug Adapter for Apache Camel 选项,然后点 Install。
这会在 VS Code 编辑器中安装 Apache Camel 的 Debug Adapter。