gpt4 book ai didi

订阅/监听 Azure 事件中心的 python 脚本?

转载 作者:太空宇宙 更新时间:2023-11-03 17:05:02 26 4
gpt4 key购买 nike

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

在 Ubuntu 上,使用 Python 2.7 和 https://pypi.python.org/pypi/python-qpid-proton/0.10在示例“receiver”脚本中,我尝试订阅如下所示的 URI:

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

返回以下错误:

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

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

最佳答案

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

虽然您说正确设置了事件中心,但我仍然建议您可以通过CONFIGURE选项卡再次检查键名称 Azure 旧门户上的事件中心页面,并确保定义的策略名称 key 名称共享访问策略中具有监听权限。或者您可以使用您的服务总线的访问连接信息中的RootManageSharedAccessKey及其 key 重试。

此外,您还可以引用 https://gist.github.com/tomconte/e2a4667185a9bf674f59 处的示例 event_hubs_receive_many.py (它基于 https://qpid.apache.org/releases/qpid-proton-0.8/messenger/python/examples/async.py.html 处的质子示例 async.py )来检查您的代码。

关于订阅/监听 Azure 事件中心的 python 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34667183/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com