295.5. 在 Apache Karaf 中运行捆绑包


使用 mvn 安装 构建捆绑包后,就可以部署它。要在 Apache Karaf 上部署捆绑包,请在 Karaf 命令行上执行以下步骤:

在 Apache Karaf 中部署捆绑包

# Add Camel feature repository
karaf@root> features:chooseurl camel 2.15-SNAPSHOT

# Install camel-scr feature
karaf@root> features:install camel-scr

# Install commons-lang, used in the example route to validate parameters
karaf@root> osgi:install mvn:commons-lang/commons-lang/2.6

# Install and start your bundle
karaf@root> osgi:install -s mvn:example/camel-scr-example/1.0-SNAPSHOT

# See how it's running
karaf@root> log:tail -n 10

Press ctrl-c to stop watching the log.
Copy to Clipboard Toggle word wrap

295.5.1. 覆盖默认配置

默认情况下,Service 组件的配置 PID 等于其类的完全限定名称。您可以使用 Karaf 的 config:* 命令更改示例捆绑包的属性:

覆盖属性

# Override 'messageOk' property
karaf@root> config:propset -p example.CamelScrExample messageOk "This is better logging"
Copy to Clipboard Toggle word wrap

或者,您可以通过编辑 Karaf 文件夹中的属性文件来更改配置。

295.5.2. 使用 Camel SCR 捆绑包作为模板

假设您有了一个 Camel SCR 捆绑包,它实施您经常使用的集成模式,,成功/失败日志记录和重新传送,这也是我们示例路由实施的模式。您可能不希望为每个实例创建单独的捆绑包。您未涵盖任何 worries。

为您的 Service 组件创建一个配置 PID,但添加一个带有短划线的尾部,而 SCR 将使用该配置来创建组件的新实例。

创建新 Service 组件实例

# Create a PID with a tail
karaf@root> config:edit example.CamelScrExample-anotherone

# Override some properties
karaf@root> config:propset camelContextId my-other-context
karaf@root> config:propset to "file://removeme?fileName=removemetoo.txt"

# Save the PID
karaf@root> config:update
Copy to Clipboard Toggle word wrap

这将使用您覆盖的属性启动新的 CamelContext。方便。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat