https://github.com/Azure/azure-event-hubs-python/blob/master/examples/eph.py
但是,该代码确实显示了关于如何检索每条消息并获取Json负载的任何代码?
我尝试了以下代码(使用用于事件中心的Python SDK):
async def process_events_async(self, context, messages):
"""
Called by the processor host when a batch of events has arrived.
This is where the real work of the event processor is done.
:param context: Information about the partition
:type context: ~azure.eventprocessorhost.PartitionContext
:param messages: The events to be processed.
:type messages: list[~azure.eventhub.common.EventData]
"""
for message in messages:
message_content = json.loads(message.body)
logger.info("Events processed {}".format(context.sequence_number))
await context.checkpoint_async()
但是,我在包含json.loads的语句中得到以下错误消息:
“2018-09-20 23:13:12484 azure错误事件处理器错误
TypeError(“JSON对象必须是str、bytes或bytearray,而不是
你能帮我获取消息的Json负载的代码吗?