Search code examples
amqpazure-eventhubqpid

How to apply filters with qpid proton against azure event hubs


I am trying to apply a filter with qpid-proton-0.17.0 against azure eventhubs. Here is my filter code:

proton::value filter_value;
proton::codec::encoder enc(filter_value);
enc << proton::codec::start::described()
    << proton::symbol("apache.org:selector-filter:string")
    << proton::binary("amqp.annotation.x-opt-offset > '100'")
    << proton::codec::finish();
proton::source::filter_map map;
proton::symbol key("apache.org:selector-filter:string");
map.put(key, filter_value);
proton::receiver_options ro;
ro.source(source_options().filters(map));

I get no messages back and eventually this error:

com.microsoft:timeout: The operation did not complete within the allocated time 
00:01:00 for object attach.

If I apply no filter, I do get the unfiltered message stream to appear. I have been able to get the filter to work with similar javascript code in nodejs using noodlefrenzy's amqp10 library. Any help on how to get my qpid code to work would be appreciated.

New note: per Xin Chen's reply, I replaced the line above

    << proton::binary("amqp.annotation.x-opt-offset > '100'")

with

    << "amqp.annotation.x-opt-offset > 100"

And this seems to work.


Solution

  • The Azure Event Hubs uses a described string as a filter to specify start position. The descriptor is a symbol "apache.org:selector-filter:string" and the value is a string. More details can be found in this page: https://github.com/Azure/amqpnetlite/blob/master/docs/articles/azure_eventhubs.md