ActiveMQ Artemis使用重复检测导致AMQ214019:配置无效:org.xml.ax.SAXParseEx



环境:

  • Ubuntu 20.04 LTS服务器64位
  • OpenJDK 11.0.15
  • ActiveMQ Artemis 2.21.0

根据集群文档,我可以在cluster-connection中使用重复消息检测。但是,因为我不需要集群连接来检测重复的消息,所以我在broker.xml中添加了<use-duplicate-detection>false</use-duplicate-detection>

当我运行artemis-service start时,我得到这个错误:

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

下面是我的broker.xml:

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

有什么建议吗?

元素的顺序实际上很重要,因为ActiveMQ Artemis配置XSD定义了xsd:sequence。因此,你应该使用这个:
<cluster-connection name="my-cluster">
<connector-ref>artemis</connector-ref>
<use-duplicate-detection>false</use-duplicate-detection>
<message-load-balancing>ON_DEMAND</message-load-balancing>
<max-hops>1</max-hops>
<discovery-group-ref discovery-group-name="dg-group1"/>
</cluster-connection>

最新更新