I'll check one more time tomorrow (I'm on the phone now) but my main concern 
has been the difference between a message that has properties which don't match 
and a message that does not have any properties at all.

Jan


________________________________
From: Justin Bertram <jbert...@apache.org>
Sent: Wednesday, September 11, 2024 3:04:42 PM
To: users@activemq.apache.org <users@activemq.apache.org>
Subject: Re: Filtering messages with no properties/headers in Artemis

What you're seeing is, in fact, the expected behavior. As noted in the
documentation [1] the ActiveMQ Artemis filter syntax is based on the same
subset of the SQL 92 syntax as JMS/Jakarta selectors and that documentation
[2] states:

    If a property that does not exist in a message is referenced, its value
is NULL.
    ...
    identifier IS NULL (comparison operator that tests for a null header
field value or a missing property value)

Therefore, if you want a queue to catch the messages that q1 and q2 miss
you'd need something like this:
 *   addr1
     *   q1 [key = 'value']
     *   q2 [NOT (key = 'value')]
     *   q3 [key is NULL]

I can't find the reference(s) at the moment, but I'm fairly certain we've
covered this on the mailing list before.


Justin

[1]
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Factivemq.apache.org%2Fcomponents%2Fartemis%2Fdocumentation%2Flatest%2Ffilter-expressions.html%23filter-expressions&data=05%7C02%7CJan.Smucr%40aimtecglobal.com%7C6e4b4f2127b7401c4ed708dcd2626171%7Cb3811028ce6e4b01bcb0db419328ffc5%7C1%7C0%7C638616567191480871%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=T2I%2BIe5EG7BulVOyxkRTOSLINHI67MhDOfAwBAywwzc%3D&reserved=0<https://activemq.apache.org/components/artemis/documentation/latest/filter-expressions.html#filter-expressions>
[2] 
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.oracle.com%2Fjavaee%2F7%2Fapi%2Fjavax%2Fjms%2FMessage.html&data=05%7C02%7CJan.Smucr%40aimtecglobal.com%7C6e4b4f2127b7401c4ed708dcd2626171%7Cb3811028ce6e4b01bcb0db419328ffc5%7C1%7C0%7C638616567191493006%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=CY2lt9Uu0XI2Xc3fLJJFKoFf5MhahFtBvfVvW0segpk%3D&reserved=0<https://docs.oracle.com/javaee/7/api/javax/jms/Message.html>



On Wed, Sep 11, 2024 at 3:46 AM Jan Šmucr <jan.sm...@aimtecglobal.com>
wrote:

> Hello.
> I've hit an odd behavior in Artemis (tested with 2.32 and 2.37), and I'd
> like to know if it's a bug or a feature.
> Say I have an anycast address `addr1` and two queues:  `q1` and `q2`. Both
> queues have a filter on them, and the `q2`'s filter is a negation of the
> `q1`'s filter. Schematically:
>
>   *   addr1
>      *   q1 [key = 'value']
>      *   q2 [NOT (key = 'value')]
> Intuitively, whatever message does not fulfill the first condition (either
> there's no `key` property, or its value is different) should be routed to
> `q2`. And that works but only as long as the message has at least some
> properties.
> In other words:
>
>   *   A message with property `key` of value `value` ends up in the `q1`
> queue.
>   *   A message with property `key` of value `foobar` ends up in the `q2`
> queue.
>   *   A message with property `foo` of value `bar` ends up in the `q2`
> queue.
>   *   And finally, a message with no properties is lost.
> Is it really supposed to work like this?
> Thanks.
> Jan
>

Reply via email to