在ArtemisMQ中的队列上设置过滤器时出错

时间:2018-07-20 08:18:06

标签: broker activemq-artemis

我在尝试通过ArtemisMQ(broker.xml)的配置在队列上配置过滤器时遇到问题:

<address name="foo">
    <multicast>
      <queue name="filtered_foo">
        <durable>true</durable>
        <filter string="bar <> 42"/>
      </queue>
    </multicast>
</address>

尝试启动经纪人时出现错误:

[Fatal Error] :207:30: The value of attribute "string" associated with an element type "filter" must not contain the '<' character.
Exception in thread "main" org.xml.sax.SAXParseException; lineNumber: 207; columnNumber: 30; The value of attribute "string" associated with an element type "filter" must not contain the '<' character.
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
    at org.apache.activemq.artemis.utils.XMLUtil.readerToElement(XMLUtil.java:90)
    at org.apache.activemq.artemis.utils.XMLUtil.stringToElement(XMLUtil.java:55)
    at org.apache.activemq.artemis.core.config.FileDeploymentManager.readConfiguration(FileDeploymentManager.java:76)
    at org.apache.activemq.artemis.integration.FileBroker.start(FileBroker.java:68)
    at org.apache.activemq.artemis.cli.commands.Run.execute(Run.java:82)
    at org.apache.activemq.artemis.cli.Artemis.internalExecute(Artemis.java:149)
    at org.apache.activemq.artemis.cli.Artemis.execute(Artemis.java:97)
    at org.apache.activemq.artemis.cli.Artemis.execute(Artemis.java:124)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.activemq.artemis.boot.Artemis.execute(Artemis.java:129)
    at org.apache.activemq.artemis.boot.Artemis.main(Artemis.java:49)

如果我在使用相同过滤条件字符串的消费者上设置选择器,则可以使用

auto consumer = session->createConsumer("foo::filtered_foo", "bar <> 42");

根据Artemis文档,config的语法必须与选择器的语法相同。有什么问题吗?

1 个答案:

答案 0 :(得分:1)

这里的问题是filter是用XML定义的,它对于允许哪些字符和不允许哪些字符有自己的规则。简而言之,您的XML无效。尝试使用此:

<filter string="bar &lt;> 42"/>

通过转义<字符,XML应该正确解析。