Configure Camel Thread names with Spring DSL

﹥>﹥吖頭↗ 提交于 2020-01-06 06:56:27

问题


How do I configure the thread names created by Camel (version 2.8.1)? I need to have more concise thread names for logging purposes.

The Camel documentation states that the default is:

Camel (#camelId#) thread ##counter# - #name#

Which results in names like:

Camel (bundle_camel) thread #114 - JmsConsumer[SomeClassNameHere]

But I want just:

#camelId#-#counter#

which would give me something like:

bundle_camel-114

The documentation says how to change the thread name pattern by calling a manager method, but we only ever interact with Camel via the Spring DSL config files.


回答1:


Yeah you would need to define a <bean> with the executor service strategy and set its pattern. Though I think we should allow to configure a naming pattern as an attribute on <camelContext> which you can do for JMX naming. I will log a ticket to get this enhanced in Camel (though ASF JIRA is currently in maintenance mode)

See some details at http://camel.apache.org/advanced-configuration-of-camelcontext-using-spring.html and http://camel.apache.org/threading-model.html




回答2:


Camel 2.11 makes this easier.

You can use the threadNamePattern attribute in the XML files as shown below:

<camelContext xmlns="http://camel.apache.org/schema/spring" threadNamePattern="#camelId#-#counter#">
  <route>
      ...
  </route>
</camelContext>

Documented here.



来源:https://stackoverflow.com/questions/13372675/configure-camel-thread-names-with-spring-dsl

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