douxiao0400 2017-12-08 10:10
浏览 80
已采纳

如何通过AMQP 1.0在Azure事件中心中批量接收许多消息

I set up an AMQP 1.0 link with just the path and a filter using the Apache Qpid Electron Go wrapper for Qpid Proton like this:

amqpConnection.Receiver(
            // the path containing the consumer group
            // and the partition Id
            electron.Source("<EVENTHUB_PATH>"),
            // the filter map contains some annotations filters 
            // for the Event Hub offset
            electron.Filter(filterMap), 
)

I followed this doc to setup the AMQP link options: https://godoc.org/qpid.apache.org/electron#LinkOption

However while running the Go app I've realised it was very slow in fetching messages, so I've added 2 more link options like this:

amqpConnection.Receiver(
            electron.Source("<EVENTHUB_PATH>"),
            electron.Capacity(100),
            electron.Prefetch(true),
            electron.Filter(filterMap),
)

but after adding the capacity and the prefetch link options I don't see any improvement in the performance.

I keep receiving approximately 10 messages every ~5 seconds from 4 parallel links (one link per partition).

I've tried to run the app with the environment variable PN_TRACE_RAW=true for the verbose output from Qpid Proton (cf. this: https://qpid.apache.org/releases/qpid-proton-0.18.0/proton/c/api/group__transport.html), but I am not sure on what should I look for to troubleshoot this issue.

I don't think there is any issue with the Qpid settings, but anyway this is what I see on the terminal:

[0x9fd490]:0 -> @attach(18) [name="<MY_CUSTOM_NAME>",
handle=1, role=true, snd-settle-mode=0, rcv-settle-mode=0, source=@source(40) [address="<MY_CUSTOM_PATH>",
durable=0, expiry-policy=:"link-detach", timeout=0, dynamic=false, filter={:string=@:"apache.org:selector-filter:string"
"amqp.annotation.x-opt-offset > '<MY_CUSTOM_OFFSET>'"}], target=@target(41) [address="",
durable=0, expiry-policy=:"link-detach", timeout=0, dynamic=false], initial-delivery-count=0,
max-message-size=0]
[0x9fd490]:0 -> @flow(19) [next-incoming-id=1, incoming-window=2147483647, next-outgoing-id=1,
outgoing-window=0, handle=1, delivery-count=0, link-credit=100, drain=false]

I also tried to run the Go app in a Azure VM in the same Azure Location as the Event Hub, but no improvement in the performance.

How could I fetch many messages at the same time in the same "round trip"? I need to process thousands of messages per seconds.

  • 写回答

1条回答 默认 最新

  • dptt66700 2017-12-13 22:22
    关注

    You are correct that you need a prefetch window but the electron client can do a LOT better than that.

    I did a quick test with the electron examples from https://github.com/apache/qpid-proton/tree/master/examples/go/electron

    I get 3000 msg/sec even without prefetch, and nearly 10000 msgs/sec with.

    $ ./broker -qsize 100000 &
    Listening on [::]:5672
    
    $  ./send -count 10000 /x ; time ./receive -count 10000 /x
    Received all 10000 acknowledgements
    Listening on 1 connections
    Received 10000 messages
    
    real    0m2.612s
    user    0m1.611s
    sys 0m0.510s
    
    $  ./send -count 10000 /x ; time ./receive -count 10000 -prefetch 1000 /x
    Received all 10000 acknowledgements
    Listening on 1 connections
    Received 10000 messages
    
    real    0m1.053s
    user    0m1.272s
    sys 0m0.277s
    

    There is clearly something funny going on - I'd like to help you get to the bottom of it.

    PN_TRACE_RAW is a bit too verbose to be helpful, try PN_TRACE_FRM=1 which will give you a more readable summary.

    I'm happy to continue the conversation either here or on users@qpid.apache.org if it turns into more of a support case than a question/answer.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号