如何针对 Azure 事件中心应用带有 qpid 质子的过滤器

How to apply filters with qpid proton against azure event hubs

我正在尝试使用 qpid-proton-0.17.0 对 azure eventhubs 应用过滤器。这是我的过滤器代码:

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

我没有收到任何消息,最终出现此错误:

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

如果我不应用过滤器,我确实会显示未过滤的消息流。我已经能够使用 noodlefrenzy 的 amqp10 库让过滤器与 nodejs 中类似的 javascript 代码一起工作。任何有关如何让我的 qpid 代码工作的帮助将不胜感激。

新注释:根据 Xin Chen 的回复,我替换了上面的行

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

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

这似乎有效。

Azure 事件中心使用描述的字符串作为过滤器来指定开始位置。描述符是一个符号"apache.org:selector-filter:string",值是一个字符串。可以在此页面中找到更多详细信息:https://github.com/Azure/amqpnetlite/blob/master/docs/articles/azure_eventhubs.md