订阅/侦听Azure Event Hub的python脚本? [英] python script which subscribes/listens to Azure Event Hub?

查看:143
本文介绍了订阅/侦听Azure Event Hub的python脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣从Python脚本监听事件中心,并在检测到入站消息时执行一些代码.

在Ubuntu上,将Python 2.7与 https://pypi.python.org一起使用/pypi/python-qpid-proton/0.10 和示例接收器"脚本,我尝试订阅一个看起来像这样的URI:

amqps://<key name>:<key>@<namespace>.servicebus.windows.net/<event hub name>/ConsumerGroups/$Default/Partitions/0

返回以下错误:

proton.MessengerException: Cannot subscribe to <...>

我相信我的事件中心设置正确,因为我能够使用单独的发送"脚本向其中发送事件,并且Azure仪表板显示事件已经到达.但是我无法以订阅者身份接收消息.

解决方案

我试图在Ubuntu Server上重现您的问题,但失败了.

尽管您说的是正确设置事件中心,但我仍然建议您可以检查key name&再次通过Azure旧门户上事件中心的CONFIGURE选项卡页key,并确保定义的策略名称key nameShared access policies中具有权限Listen.或者您可以使用RootManageSharedAccessKey&再次输入您的服务总线的访问连接信息中的密钥.

此外,您可以在 https://gist.github.com/上参考示例event_hubs_receive_many.py. tomconte/e2a4667185a9bf674f59 (基于质子样本async.py,位于https://pypi.python.org/pypi/python-qpid-proton/0.10 and the example "receiver" script, I attempt to subscribe to a URI that looks like:

amqps://<key name>:<key>@<namespace>.servicebus.windows.net/<event hub name>/ConsumerGroups/$Default/Partitions/0

The following error is returned:

proton.MessengerException: Cannot subscribe to <...>

I believe that my Event Hub is set up correctly because I am able to send events into it using a separate "send" script and the Azure dashboard shows that events have arrived. But I am unable to connect as a subscriber to receive messages.

解决方案

I tried to reproduce your issue on Ubuntu Server, but failed.

Although you said set up your event hub correctly, I still suggest you can check the key name & key again via the CONFIGURE tab page of your event hub on Azure old portal and make sure the policy name key name defined that has the permission Listen in the Shared access policies. Or you can use RootManageSharedAccessKey & its key in the access connection information of your service bus to try again.

Also, you can refer to the sample event_hubs_receive_many.py at https://gist.github.com/tomconte/e2a4667185a9bf674f59 (it based on the proton sample async.py at https://qpid.apache.org/releases/qpid-proton-0.8/messenger/python/examples/async.py.html) to check your code.

这篇关于订阅/侦听Azure Event Hub的python脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆