ActiveMQ Artemis配置use-duplicate-detection触发AMQ214019错误求助
ActiveMQ Artemis 2.21.0 cluster-connection配置错误解决建议
环境
- Ubuntu 20.04 LTS Server 64bit
- OpenJDK 11.0.15
- ActiveMQ Artemis 2.21.0
问题
根据集群文档尝试禁用cluster-connection的重复消息检测功能,在broker.xml的cluster-connection节点中添加了<use-duplicate-detection>false</use-duplicate-detection>配置,但执行artemis-service start启动服务时触发XML配置验证错误。
错误信息
2022-07-31 18:52:02,335 ERROR [org.apache.activemq.artemis.core.client] AMQ214019: Invalid configuration: org.xml.sax.SAXParseException; cvc-complex-type.2.4.a: Invalid content was found starting with element '{"urn:activemq:core":use-duplicate-detection}'. One of '{"urn:activemq:core":max-hops, "urn:activemq:core":confirmation-window-size, "urn:activemq:core":producer-window-size, "urn:activemq:core":call-failover-timeout, "urn:activemq:core":notification-interval, "urn:activemq:core":notification-attempts, "urn:activemq:core":scale-down-connector, "urn:activemq:core":static-connectors, "urn:activemq:core":discovery-group-ref}' is expected. at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204) [java.xml:] at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:135) [java.xml:] at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396) [java.xml:] at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) [java.xml:] at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284) [java.xml:] at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:511) [java.xml:] at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3587) [java.xml:] at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1971) [java.xml:] at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:829) [java.xml:] at java.xml/com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.beginNode(DOMValidatorHelper.java:276) [java.xml:] at java.xml/com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:243) [java.xml:] at java.xml/com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:189) [java.xml:] at java.xml/com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:108) [java.xml:] at java.xml/javax.xml.validation.Validator.validate(Validator.java:124) [java.xml:] at org.apache.activemq.artemis.utils.XMLUtil.validate(XMLUtil.java:361) [artemis-core-client-2.21.0.jar:]
相关配置片段
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> <core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq:core "> ... <cluster-user>cluster</cluster-user> <cluster-password>cluster</cluster-password> <broadcast-groups> <broadcast-group name="bg-group1"> <group-address>231.7.7.8</group-address> <group-port>9876</group-port> <broadcast-period>5000</broadcast-period> <connector-ref>artemis</connector-ref> </broadcast-group> </broadcast-groups> <discovery-groups> <discovery-group name="dg-group1"> <group-address>231.7.7.8</group-address> <group-port>9876</group-port> <refresh-timeout>10000</refresh-timeout> </discovery-group> </discovery-groups> <cluster-connections> <cluster-connection name="my-cluster"> <connector-ref>artemis</connector-ref> <message-load-balancing>ON_DEMAND</message-load-balancing> <use-duplicate-detection>false</use-duplicate-detection> <max-hops>1</max-hops> <discovery-group-ref discovery-group-name="dg-group1"/> </cluster-connection> </cluster-connections> ... </core> </configuration>
解决建议
从错误信息和XML schema验证结果来看,ActiveMQ Artemis 2.21.0的cluster-connection节点并不支持<use-duplicate-detection>配置项,该配置是后续版本才新增的,所以添加这个元素会触发XML结构验证失败。
你可以采取以下两种方案:
- 方案一:直接移除
cluster-connection节点中的<use-duplicate-detection>false</use-duplicate-detection>配置,重新启动服务即可恢复正常。 - 方案二:如果业务确实需要禁用集群连接的重复消息检测功能,可以将ActiveMQ Artemis升级到支持该配置的版本(如2.22.0及以上),升级后再添加该配置即可正常启动。
内容的提问来源于stack exchange,提问作者wureka
相关产品推荐
相关产品推荐

