Closed Shikha4599 closed 2 years ago
Hi @Shikha4599,
Thanks for your issue.
Could you please test this implementation for ABC.cs
:
public class ABC : AbstractSerDes<ABC>
{
public string Name { get; set; }
public int Data { get; set; }
public override ABC Deserialize(byte[] data, SerializationContext context)
{
var bytesAsString = Encoding.UTF8.GetString(data);
return JsonConvert.DeserializeObject<ABC>(bytesAsString);
}
public override byte[] Serialize(ABC data, SerializationContext context)
{
var a = JsonConvert.SerializeObject(data);
return Encoding.UTF8.GetBytes(a);
}
}
By the way, it's not a good practice to use the same class for the BEAN and the SerDes. I recommend you to split into two different classes.
@Shikha4599,
Looks like your value in the source kafka topic is null. If not, maybe you have to add a breakpoint into the ABC serdes in the Deserialize(..)
method to observe the behavior during the deserialiazation ?
Your filter could have v!=null && v.Data...
Hi @Shikha4599,
Thanks for your issue.
Could you please test this implementation for
ABC.cs
:public class ABC : AbstractSerDes<ABC> { public string Name { get; set; } public int Data { get; set; } public override ABC Deserialize(byte[] data, SerializationContext context) { var bytesAsString = Encoding.UTF8.GetString(data); return JsonConvert.DeserializeObject<ABC>(bytesAsString); } public override byte[] Serialize(ABC data, SerializationContext context) { var a = JsonConvert.SerializeObject(data); return Encoding.UTF8.GetBytes(a); } }
This worked. Thankyou so much for the response @LGouellec
@Shikha4599
Perfect ! So I close this issue. If you have another question/issue, please open a new one.
Description We have made our consumer class where we are consuming messages from Kafka producer. We wanted to customize our Kafka stream by providing customized class in DefaultValueSerDes, which is not working and giving me error.
THIS IS MY PROGRAM.CS FILE ` // Stream configuration var config = new StreamConfig();
THIS IS MY PROVIDED JSON TYPE IN KAFKA PRODUCER {"Name": "DND", "Data": 37}
THIS IS MY CUSTOMIZED CLASS ABC.CS ` public class ABC : ISerDes { public string Name { get; set; } public int Data { get; set; }
THIS IS THE ERROR WE ARE RECEIVING
How to reproduce
Checklist
Please provide the following information: