2.12. JMX Naming
来源:互联网 发布:第三语言学什么 知乎 编辑:程序博客网 时间:2024/05/16 05:38
Overview
Apache Camel allows you to customise the name of a CamelContext bean as it appears in JMX, by defining a management name pattern for it. For example, you can customise the name pattern of an XML CamelContext instance, as follows:
<camelContext id="myCamel" managementNamePattern="#name#"> ...</camelContext>
If you do not explicitly set a name pattern for the CamelContext bean, Apache Camel reverts to a default naming strategy.
Default naming strategy
By default, the JMX name of a CamelContext bean is equal to the value of the bean’s id attribute, prefixed by the current bundle ID. For example, if the id attribute on a camelContext element is myCamel and the current bundle ID is 250, the JMX name would be 250-myCamel. In cases where there is more than one CamelContext instance with the same id in the bundle, the JMX name is disambiguated by adding a counter value as a suffix. For example, if there are multiple instances of myCamel in the bundle, the corresponding JMX MBeans are named as follows:
250-myCamel-1250-myCamel-2250-myCamel-3...
Customising the JMX naming strategy
One drawback of the default naming strategy is that you cannot guarantee that a given CamelContext bean will have the same JMX name between runs. If you want to have greater consistency between runs, you can control the JMX name more precisely by defining a JMX name pattern for the CamelContext instances.
Specifying a name pattern in Java
To specify a name pattern on a CamelContext in Java, call the setNamePattern method, as follows:
// Javacontext.getManagementNameStrategy().setNamePattern("#name#");
Specifying a name pattern in XML
To specify a name pattern on a CamelContext in XML, set the managementNamePattern attribute on the camelContext element, as follows:
<camelContext id="myCamel" managementNamePattern="#name#">
Name pattern tokens
You can construct a JMX name pattern by mixing literal text with any of the following tokens:
Table 2.11. JMX Name Pattern Tokens
Examples
Here are some examples of JMX name patterns you could define using the supported tokens:
<camelContext id="fooContext" managementNamePattern="FooApplication-#name#"> ...</camelContext><camelContext id="myCamel" managementNamePattern="#bundleID#-#symbolicName#-#name#"> ...</camelContext>
Ambiguous names
Because the customised naming pattern overrides the default naming strategy, it is possible to define ambiguous JMX MBean names using this approach. For example:
<camelContext id="foo" managementNamePattern="SameOldSameOld"> ... </camelContext>...<camelContext id="bar" managementNamePattern="SameOldSameOld"> ... </camelContext>
In this case, Apache Camel would fail on start-up and report an MBean already exists exception. You should, therefore, take extra care to ensure that you do not define ambiguous name patterns.
- 2.12. JMX Naming
- naming
- naming
- Failed to register in JMX: javax.naming.NamingException: Could not load resource factory class
- Failed to register in JMX: javax.naming.NamingException: Could not load resource factory class
- Failed to register in JMX: javax.naming.NamingException: Could not load resource factory class
- JMX
- JMX
- JMX
- JMX
- jmx
- JMX
- JMX
- jmx
- jmx
- JMX
- JMX
- jmx
- php配置默认页
- 高质量iOS代码(OC 版)
- 在<body>中引入JavaScript
- 去哪里捕捉和观察趋势
- L1-003. 个位数统计
- 2.12. JMX Naming
- 每天一个 Linux 命令(17):whereis 命令
- Java Map数据结构与排序
- 如何解决web项目没有生成web.xml文件?
- 程序员的思维修炼 开发认知潜能的九堂课 读书笔记
- sigaction检测段错误示例
- thinkphp--foreach循环里面的jquery+ajax的点击事件的数据同步
- ITOO遇到的问题
- 2.13. Performance and Optimization