Azure Bus pint server issue

I am using azure Service Bus for the first time to pass a message between a C # source and a python client.

I create a ServiceBusService object and use it. I am getting a message from the receive_subscription_message function .

The payload I am receiving is not as expected.

My code looks something like this.

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 string of bytes as shown below:   b'@\x06string\x083http://schemas.microsoft.com/2003/10/Serialization/\x9ae\x0c{"PUID":"3NFLzV3cjCp8f5JLh3KSnkXDgSw1FWgM","HardDelete":null}\x01'

Initially, json was inserted into it. Is there a way to avoid extra parameters and only select the original json?

+3


source to share


1 answer


The problem was caused by a different protocol used on the other side: sender in C # using AMQP, or .NET default serialization behavior and receiver in Python using REST API over HTTP. You can refer to the Azure Python Service Bus SDK doc Using Service Bus from .NET with AMQP 1.0

and source code to learn about this, and I explained a similar issue in another SO post on Azure Service Bus Security Message Messages .

To avoid extra parameters and only select original json, you can try two ways as below.



  • Using REST API over HTTP in C # to send original json without any extra content from AMQP or default .NET serialization behavior.
  • Usage python-qpid-proton

    in Python message to receiver with AMQP to deserialize and get original json.
  • In the current case, just remove the add content from the posts to extract the original json code, due to the post has the same add content.

Hope it helps.

+4


source







All Articles