Getting serialization error when publish message to KAFKA topic

喜夏-厌秋 提交于 2019-12-25 02:35:08

问题


I'm using program variables to create configuration objects and loading the schema from a local path which also been registered in kafka.

Creating data object and using "Generic Record" method of serializing.

                var logMessageSchema =(Avro.RecordSchema)Avro.Schema.Parse(File.ReadAllText(@"C:\StatusMessageSchema\FileStatusMessageSchema.txt"));
                var record = new GenericRecord(logMessageSchema);

                record.Add("SystemID", "100");
                record.Add("FileName", "ABS_DHCS");
                record.Add("FileStatus", "3009");
                record.Add("TotalMembers", "400");
                record.Add("PlanType", "CA");
                record.Add("HippaLevel", "10");
                try
                { 
                    var dr = await producer.ProduceAsync(topicname, new Message<Null, GenericRecord> { Value = record });
                        Console.WriteLine($"### Message Published ###\n" + "Topic Name : " + "{0}\n" + "Partition ID : " + "{1}\n" + "Offset ID : " + "{2}\n", dr.Topic, dr.Partition, dr.Offset);
                        Console.WriteLine();
                }
                catch (ProduceException<Null, string> e)
                {
                    Console.WriteLine("Delivery failed: {0}", e.Error.Reason);
                }

来源:https://stackoverflow.com/questions/57681875/getting-serialization-error-when-publish-message-to-kafka-topic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!