问题
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