0

I am using Azure service bus to view message contents of a messages sent from an service bus service.

I am using the message.get_message() command and it returns a c message as specified in the documentation https://learn.microsoft.com/en-us/python/api/uamqp/uamqp.message.message?view=azure-python

Is there a way to view the contents of the c message?

<uamqp.c_uamqp.cMessage object at 0x0000000003180F50>

1 Answer 1

1

What do you mean about the contents of the c message?

I think the content of the c message you received is the date to send in the message. So according to the offical API reference Message class, you should use message.get_data() to get the body of the message to view its content, as the figure below.

enter image description here

Or just only to view it by print(...) like the sample code azure-uamqp-python/samples/sample_uamqp_receive_simple.py.

message = uamqp.receive_message(uri, auth=plain_auth)
print("Received: {}".format(message))

If your real intention is to parse the uamqp.c_uamqp.cMessage data structure of the massage to view the internal contents, you can refer to the SO thread Parsing C Structs in Python with the source codes message.h & message.c of Azure/azure-uamqp-c and the Python wrapper code message.pyx to try to parse it.

After I reviewed them above, the core data structure of uamqp.c_uamqp.cMessage is as below.

typedef struct MESSAGE_INSTANCE_TAG
{
    BODY_AMQP_DATA* body_amqp_data_items;
    size_t body_amqp_data_count;
    AMQP_VALUE* body_amqp_sequence_items;
    size_t body_amqp_sequence_count;
    AMQP_VALUE body_amqp_value;
    HEADER_HANDLE header;
    delivery_annotations delivery_annotations;
    message_annotations message_annotations;
    PROPERTIES_HANDLE properties;
    application_properties application_properties;
    annotations footer;
    uint32_t message_format;
} MESSAGE_INSTANCE;

Hope it helps.

Sign up to request clarification or add additional context in comments.

1 Comment

great answer! thanks quick update: the latest servicebus version v7.0.0 changes this a little bit - please take a look at learn.microsoft.com/en-us/python/api/azure-servicebus/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.