I have a subscription to a topic using filters in Azure Service Bus
develop with Python 3.x
and when I wait the information sent to that topic (information that pass the filter) I can not receive it.
I need to create a daemon that is always listening and that when I receive that information I send it to an internal service of my application, so the receiver is running in a thread inside a loop While True
The code I use to receive the messages is as follows:
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()
What I get when I run it is the next information:
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'
If I run the receiver out of the thread, this is the error message it shows (again when the timeout is skipped, which timeout I should delete because in a daemon that is waiting it can not skip). Basically, it is the same error:
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'
I do not receive the information I'm waiting and also skip a Service Bus timeout (which I have not programmed).
Can anybody help me? Microsoft's documentation does not help much, really.
Thanks in advance
UPDATE
I think that the problem is from Azure Service Bus and the subscriptions and filters. Actually, I have 23 filters and I think Azure Service Bus only works with 1 subscription :( But I'm not sure about this point.
msg
? My guess is that you're not getting anything back from the Service Bus. – Gaurav Mantri