【问题标题】:How to apply filters with qpid proton against azure event hubs如何使用 qpid proton 对 azure 事件中心应用过滤器
【发布时间】:2017-09-20 00:41:47
【问题描述】:

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

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 代码工作的帮助将不胜感激。

新说明:根据新陈的回复,我替换了上面的那行

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

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

这似乎有效。

【问题讨论】:

  • 过滤值需要是字符串。您输入的 proton::binary 值可能存在问题。
  • 是的,这行得通,@Xin。非常感谢。从上面的代码中删除 proton::binary 解决了我的问题。也许你可以发布作为答案。我使用了 qpid 的 selected_recv.cpp 示例代码,他们确实使用了二进制文件,但显然 azure event hub 的做法不同。
  • @GregClinton 您还可以编辑和编写更正后的代码。如果您删除了二进制文件,那么您是如何通过条件的?

标签: amqp azure-eventhub qpid


【解决方案1】:

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

【讨论】:

  • 那么如何将这样的选择器传递给 qpid?设置一个选择器,如:amqp.annotation.x-opt-offset > 1 并将其作为选择器传递以创建消费者,似乎不起作用。 consumer = session.createConsumer(queue, selector);
猜你喜欢
  • 2017-06-09
  • 2015-12-26
  • 2018-07-12
  • 2016-08-06
  • 1970-01-01
  • 2016-01-13
  • 2015-11-18
  • 2015-03-04
  • 2017-07-01
相关资源
最近更新 更多