You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Jesus Martín González <je...@neodoo.es> on 2022/07/08 10:57:10 UTC

FilterExpression not valid for MQTT 5 user property

Hi,

I am facing some problems while trying to filter messages.

I am using a MQTT 5 client to send messages with a user property with the
key "provider" and the value "provider1".

When it's received in a queue, browsing it in the artemis console, i can
see that the property key has been transformed to:
"mqtt.ordered.user.property.0.provider".

Then when i try to create a new queue with a filter for this key, it throws
an error for invalid filter expression. Inspecting logs, it seems that the
dots are the problem.

I have tried like 30 different ways to put the expression (Following JMS
selector docs and others) but I am not getting the desired result and
messages are not being filtered.

I have checked Apache artemis code in github and I can see a class called
MQTTUtil.java which is the one that is transforming the property and
inserting those dots.

¿Is there a way to filter correctly by this key or is it a bug in artemis
code?

Thanks! Regards



[image:
https://www.certmetrics.com/amazon/public/badge.aspx?i=1&t=c&d=2019-12-05&ci=AWS00740038]
<https://www.youracclaim.com/badges/2f39e59d-cebd-4ecd-a1f8-73ef24607021/public_url>

*JESÚS MARTÍN GONZÁLEZ*

Desarrollo de Software

jesus.martin@neodoo.es

(+34) 654420529



<https://twitter.com/neodoo_tweets/>
<https://www.linkedin.com/company/neodoo-microsystems/>
<http://neodoo.es/>

Re: FilterExpression not valid for MQTT 5 user property

Posted by Justin Bertram <jb...@apache.org>.
I looked into this and I was able to create a JMS consumer with a valid
selector to get messages with a specific property value sent from an MQTT 5
client. In my test the MQTT 5 client sent a message with a property named
"foo" with a value of "bar" and I created my JMS consumer this way:

  MessageConsumer mc = s.createConsumer(myDestination,
"\"mqtt.ordered.user.property.0.foo\" = 'bar'");

Notice the quotation marks around the property name. Have you tried this
solution in your 30 different attempts?

That said, there is a problem with the naming convention used for the
properties. The naming convention was designed to allow the broker to track
the *order* of the properties on the MQTT message because maintaining order
is required by the spec. However, I just realized that the part of the
property name which tracks the order is going to cause difficulties for any
non-MQTT client that wants to use a selector/filter to consume them. In
short, if the order of the properties changes in the MQTT message then the
selector/filter will also have to change. I don't think this is tenable and
I plan on implementing a new solution where the original name of the
property is preserved and order is maintained in some other way.


Justin

On Fri, Jul 8, 2022 at 6:02 AM Jesus Martín González <je...@neodoo.es>
wrote:

> Hi,
>
> I am facing some problems while trying to filter messages.
>
> I am using a MQTT 5 client to send messages with a user property with the
> key "provider" and the value "provider1".
>
> When it's received in a queue, browsing it in the artemis console, i can
> see that the property key has been transformed to:
> "mqtt.ordered.user.property.0.provider".
>
> Then when i try to create a new queue with a filter for this key, it throws
> an error for invalid filter expression. Inspecting logs, it seems that the
> dots are the problem.
>
> I have tried like 30 different ways to put the expression (Following JMS
> selector docs and others) but I am not getting the desired result and
> messages are not being filtered.
>
> I have checked Apache artemis code in github and I can see a class called
> MQTTUtil.java which is the one that is transforming the property and
> inserting those dots.
>
> ¿Is there a way to filter correctly by this key or is it a bug in artemis
> code?
>
> Thanks! Regards
>
>
>
> [image:
>
> https://www.certmetrics.com/amazon/public/badge.aspx?i=1&t=c&d=2019-12-05&ci=AWS00740038
> ]
> <
> https://www.youracclaim.com/badges/2f39e59d-cebd-4ecd-a1f8-73ef24607021/public_url
> >
>
> *JESÚS MARTÍN GONZÁLEZ*
>
> Desarrollo de Software
>
> jesus.martin@neodoo.es
>
> (+34) 654420529
>
>
>
> <https://twitter.com/neodoo_tweets/>
> <https://www.linkedin.com/company/neodoo-microsystems/>
> <http://neodoo.es/>
>