Pustovalov Dmitry
Pustovalov Dmitry

Reputation: 1047

Error while setting filter on queue in ArtemisMQ

I have a problem trying to configure filter on queue through config for ArtemisMQ (broker.xml):

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

Trying start broker I have an error:

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

If I set selector on consumer with same filter string it works:

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

According to Artemis documentation syntax for config must be the same as for selectors. What's the problem?

Upvotes: 0

Views: 422

Answers (1)

Justin Bertram
Justin Bertram

Reputation: 35038

The issue here is that the filter is being defined in XML which has its own rules for what characters are allowed and what characters are not allowed. Simply put, your XML isn't valid. Try using this:

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

By escaping the < character the XML should parse correctly.

Upvotes: 1

Related Questions