如何从外部更新骆驼属性? [英] How to update camel properties externally?

查看:24
本文介绍了如何从外部更新骆驼属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发非 OSGI 应用程序,我需要更新骆驼路线中使用的某些属性的值(加载的 BridgePropertyPlaceHolder).所以我想:

Im developping non OSGI app and i need to update the values ​​of some properties used in camel routes (loaded BridgePropertyPlaceHolder). So I thought:

  • 使用 Hawtio,这个很酷的管理控制台,以便使用 JMX 更新骆驼

  • To use Hawtio, the cool mangement console, in order update camel using JMX

创建一个将更新属性的 JMX MBean ..

Create a JMX MBean that will update the properties ..

我成功创建了 MBean 操作并使用 JMX 调用它们,但我不知道如何更新依赖于这些属性的骆驼路由.

I successfully create the MBean operations and call them using JMX, but I can't figure out how to update the camel routes that depends on these properties.

有没有办法从外部更新骆驼上下文?

Is there a way to update the camel context externally?

更新:用例示例:当远程服务器没有返回响应时,我们会继续发送消息,直到达到不成功尝试的最大值(没有 ack 的消息).在骆驼中,我们根据从文件系统加载的属性创建了一个路由器模式.这个属性偶尔会改变,我们想在不重启服务器的情况下做到这一点,但问题是骆驼在启动上下文时解析路由,我找不到相应地更新路由的方法.

Update: Exemple of use case:when a remote server doesn't return response, we keep sending messages until we reach the max of unsuccessful attempt(messages without ack). in camel we create a router pattern based on property loaded from file system. This property can change occasionally, and we want to do this without restarting server, but the problem is that camel parse routes when starting context and i can't find no mean to update routes accordingly.

我很感激任何可以提供帮助的建议:)

I am grateful for any proposal that could help:)

推荐答案

如果你使用 Camel 错误处理来重试(redeliver)那么你可以使用 retryWhile 继续重试直到你返回 错误.这允许您使用 java 代码等,并允许您阅读更新的配置选项.

If you use Camel error handling to retry (redeliver) then you can use the retryWhile to keep retrying until you return false. This allows you to use java code etc, and that allows you to read the updated configuration option.

查看更多详情

如果您有《骆驼行动》一书,请参阅第 152 页

And if you have a copy of Camel in Action book, see page 152

这篇关于如何从外部更新骆驼属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆