Reputation: 414
I am using azure service bus for the first time to transfer message between C# source and python client.
I am creating ServiceBusService object and using it i fetch message from function receive_subscription_message.
The payload i get is not as expected.
My code is something like below.
bus_service = ServiceBusService(service_namespace="service_namespace", shared_access_key_name="All", shared_access_key_value="password")
msg = bus_service.receive_subscription_message('test', 'test', peek_lock=True)
print(msg.body)
msg.delete()
msg.body gives a byte string like below:
b'@\x06string\x083http://schemas.microsoft.com/2003/10/Serialization/\x9ae\x0c{"PUID":"3NFLzV3cjCp8f5JLh3KSnkXDgSw1FWgM","HardDelete":null}\x01'
Originally json was pushed in it. Is there any way to avoid additional parameters and fetch original json only?
Upvotes: 4
Views: 1326
Reputation: 24138
The issue was caused by the different protocol used at the different side: sender in C# using AMQP or default .NET serialization behavior and receiver in Python using REST API via HTTP. You can refer to the document Using Service Bus from .NET with AMQP 1.0
and the source code of Azure Python Service Bus SDK to know that, and I had explained the similar issue in the other SO thread Interoperability Azure Service Bus Message Queue Messages.
To avoid additional parameters and fetch original json only, there are two ways which you can try, as below.
python-qpid-proton
package in Python to receiver message with AMQP to deserialize and get the original json.Hope it helps.
Upvotes: 5