Event hub - Schema registry - Avro Consumer not deserializing using .Net Core

Hello,
I am trying to de-serialize event hub event which is Avro based.
I have written code based on the article (https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/schemaregistry/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro) but event is not getting de-serialized.
Also, there is no error or exception. Any pointer on this is really helpful.
try
{
// Create a producer client that you can use to send events to an event hub
EventHubConsumerClient consumerClient = new EventHubConsumerClient(EventHubConsumerClient.DefaultConsumerGroupName, connectionString, eventHubName);
// Create a schema registry client that you can use to serialize and validate data.
var schemaRegistryClient = new SchemaRegistryClient(schemaRegistryEndpoint, credential: new DefaultAzureCredential());
var serializer = new SchemaRegistryAvroSerializer(schemaRegistryClient, schemaGroup, new SchemaRegistryAvroSerializerOptions { AutoRegisterSchemas = true });
await foreach (PartitionEvent receivedEvent in consumerClient.ReadEventsAsync())
{
MessageContent msgContent = new MessageContent();
msgContent.Data = receivedEvent.Data.EventBody;
msgContent.ContentType = "avro/binary+schemaId";
var deserialized = (Shipment) await serializer.DeserializeAsync(msgContent, typeof(Shipment));
Console.WriteLine(deserialized.ordernumber);
Console.WriteLine(deserialized.shipmentnumber);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
@HimanshuSinha-msft thank you for reply.
Event hub events are stored as binary data. I want to read events in my consumer application and want to de-serialize it to class object so I can process it further. But the above code is not giving any error and it is not populating entity object either. After execution of line 11, object "deserialized" is null. There is no error or exception at all.
Event has data in it, and it is not empty or null. I have converted event binary data to string, and I can see the data. So my issue is why line 11 [var deserialized = (Shipment) await serializer.DeserializeAsync(msgContent, typeof(Shipment));] is not working as expected if there is no error.
Just to give you some background, my producer is Java based and it is posting Avro events to event hub using Kafka protocol. My consumer is .Net core based and I am trying to read the Avro events and want it back in class object for further processing.
I have also written Java based consumer using Kafka protocol and it is working as expected without any issue. But with .Net core consumer, I am having this trouble.
Hope this detail will help. Let me know if you need any other detail.
Hello Team,
Any update on this issue? I am still having this issue.
Hello @DS ,
Thanks for the patience , unfortunately we are not getting the kind of response from the team here . if you have a support plan you may file a support ticket, else could you please send an email to azcommunity@microsoft.com with the below details, so that we can create a one-time-free support ticket for you to work closely on this matter.
Subscription ID:
Subject : Attn Himanshu
Please let me know once you have done the same.
Thanks
Himanshu
Hello @DS ,
We haven’t received any email from you as requested in the last response and was just checking back to see if you have a resolution . In case if you have any resolution please do share that same with the community as it can be helpful to others . Otherwise, please respond back with the more details as requested and we will try to help .
Thanks
Himanshu
Hello @HimanshuSinha-msft ,
Still, I do not have solution for this problem and exploring other routes to achieve this. But no success as of now. I do not have any support plan as this is internal POC for us. Can you help me to create internal ticket for this for one time support? This is absolutely necessary feature as publisher can be written in any language and consumer can be completely on different language.
Thank you for checking on this.
Hello @DS ,
Sorry to know that the issue is not resolved .
As suggested above , please send an email to azcommunity@microsoft.com with the below details, so that we can create a one-time-free support ticket for you to work closely on this matter.
Subscription ID:
Subject : Attn Himanshu
Please let me know once you have done the same.
Thanks
Himanshu
Sign in to comment