我在Azure Service Bus
开发中使用过滤器订阅了一个主题Python 3.x
,当我等待发送到该主题的信息(通过过滤器的信息)时,我无法接收它。
我需要创建一个始终在监听的守护进程,当我收到该信息时,我会将其发送到应用程序的内部服务,因此接收器在循环内的线程中运行While True
我用来接收消息的代码如下:
while True:
msg = bus_service.receive_subscription_message(topic_name, subscription_name, peek_lock=True)
print('Mensaje Recibido-->',msg.body)
data = msg.body
send_MyApp(data.decode("utf-8"))
msg.delete()
我运行它时得到的是下一个信息:
Message --> None
Exception in thread Thread-1:
Traceback (most recent call last):
File "..\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "..\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "../Python/ServiceBusSuscription/receive_subscription.py", line 19, in receive_subscription
send_MyApp(data.decode("utf-8"))
AttributeError: 'NoneType' object has no attribute 'decode'
如果我从线程中运行接收器,这就是它显示的错误消息(同样,当超时被跳过时,我应该删除哪个超时,因为在等待它的守护进程中它不能跳过)。基本上,这是相同的错误:
Traceback (most recent call last):
File "../Python/ServiceBusSuscription/receive_subscription.py", line 76, in <module>
main()
File "../Python/ServiceBusSuscription/receive_subscription.py", line 72, in main
demo(bus_service)
File "../Python/ServiceBusSuscription//receive_subscription.py", line 25, in demo
print(msg.body.decode("utf-8"))
AttributeError: 'NoneType' object has no attribute 'decode'
我没有收到我正在等待的信息,也跳过了服务总线超时(我没有编程)。
有谁能够帮我?微软的文档并没有太大帮助,真的。
提前致谢
更新
我认为问题出在 Azure 服务总线以及订阅和筛选器上。实际上,我有 23 个过滤器,我认为 Azure 服务总线仅适用于 1 个订阅 :( 但我不确定这一点。