How to update camel properties externally?

匆匆过客 提交于 2019-12-20 06:25:49

问题


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

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

  • Create a JMX MBean that will update the properties ..

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?

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:)


回答1:


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.

See more details at

  • http://camel.apache.org/exception-clause.html

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




回答2:


For what properties you want them to be dynamic.you can move those prop to some db and fetch them whenever you are reading.I think a redesign is required for your camel route.




回答3:


Changing from endpoint parameters such as URLs etc., following procedure has to be used according to dynamic change endpoint camel:

  1. stop the route
  2. remove the route
  3. change the endpoint
  4. add the route
  5. start the route

If the to endpoint has to be configurable, you may use the recipient list component. Here you may read properties from a database and/or from the filesystem using the appropriate Camel component.



来源:https://stackoverflow.com/questions/23713711/how-to-update-camel-properties-externally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!