Providing custom class as a DefaultValueSerDes giving an error
See original GitHub issueDescription 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();
config.ApplicationId = "app-testing";
config.BootstrapServers = "localhost:9092";
config.DefaultKeySerDes = new StringSerDes();
config.DefaultValueSerDes = new ABC();
StreamBuilder builder = new StreamBuilder();
IKStream<string, ABC> str = builder.Stream<string, ABC>("test-input");
str.Filter((k, v) => v.Data >= 25 && v.Data <= 50).To("test-output");
Topology t = builder.Build();
// Create a stream instance with topology and configuration
KafkaStream stream = new KafkaStream(t, config);
// Subscribe CTRL + C to quit stream application
Console.CancelKeyPress += (o, e) =>
{
stream.Dispose();
};
// Start stream instance with cancellable token
await stream.StartAsync(); `
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; }
public object DeserializeObject(byte[] data, SerializationContext context)
{
var bytesAsString = Encoding.UTF8.GetString(data);
return JsonConvert.DeserializeObject<ABC>(bytesAsString);
}
public void Initialize(SerDesContext context)
{
context.Config.BootstrapServers = "localhost:9092";
context.Config.ApplicationId = "app-testing";
}
public byte[] SerializeObject(object data, SerializationContext context)
{
var a = JsonConvert.SerializeObject(data);
return Encoding.UTF8.GetBytes(a);
}
}`
THIS IS THE ERROR WE ARE RECEIVING
How to reproduce
Checklist
Please provide the following information:
- A complete (i.e. we can run it), minimal program demonstrating the problem. No need to supply a project file.
- A code snippet with your topology builder (ex: builder.Stream<string, string>(“topic”).to(“an-another-topic”)😉
- Streamiz.Kafka.Net nuget version.
- Apache Kafka version.
- Client configuration.
- Operating system.
- Provide logs (with in debug mode (log4net and StreamConfig.Debug) as necessary in configuration).
- Critical issue.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Providing custom class as a DefaultValueSerDes giving an ...
We wanted to customize our Kafka stream by providing customized class in DefaultValueSerDes, which is not working and giving me error.
Read more >python - Reasoning behind custom class Exception
I am learning Python and when I learned that we can build Custom classes for exception, I got into a confusion of Why...
Read more >How to Define Custom Exception Classes in Python
The construction of custom exception classes can enrich our class design. A custom error class could logs errors, inspect an object.
Read more >Game crashing when custom classes are used in a script
Hi, I've been working on a game in Godot 4 since beta but now I've stumbled across a very strange error. When I...
Read more >ehmicky/error-custom-class: Create custom error classes
This package works in both Node.js >=16.17.0 and browsers. This is an ES module. It must be loaded using an import or import()...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Shikha4599
Perfect ! So I close this issue. If you have another question/issue, please open a new one.
This worked. Thankyou so much for the response @LGouellec