C# Kafka Net中生成的消息中没有时间戳

C# Kafka Net中生成的消息中没有时间戳,c#,apache-kafka,kafka-producer-api,C#,Apache Kafka,Kafka Producer Api,我正在使用Kafka Net nuget包为Kafka的制作和消费做一个基本的POC 但是,我的问题是,它发布到主题的消息似乎没有任何时间戳(在Kafka工具最新版本中查看时)。这是因为Kafka Net软件包没有更新以支持新版本Kafka中处理时间戳的方式吗?我需要改用合流卡夫卡吗 消息被附加到具有正确偏移量和有效负载的主题,它们只有一个空的时间戳 这是我的密码 using System; using System.Collections.Generic; using System.Confi

我正在使用Kafka Net nuget包为Kafka的制作和消费做一个基本的POC

但是,我的问题是,它发布到主题的消息似乎没有任何时间戳(在Kafka工具最新版本中查看时)。这是因为Kafka Net软件包没有更新以支持新版本Kafka中处理时间戳的方式吗?我需要改用合流卡夫卡吗

消息被附加到具有正确偏移量和有效负载的主题,它们只有一个空的时间戳

这是我的密码

using System;
using System.Collections.Generic;
using System.Configuration;
using KafkaNet;
using KafkaNet.Model;
using KafkaNet.Protocol;

namespace KafkaProducer
{
    class Program
    {
        static void Main(string[] args)
        {
            var brokerUri = ConfigurationManager.AppSettings["BrokerUri"];

            Console.WriteLine("Enter the topic name to publish to");
            var topicName = Console.ReadLine();

            Console.WriteLine();
            Console.WriteLine($"Now publishing to topic {topicName}, enter messages separated by a carriage return");
            Console.WriteLine();

            var uri = new Uri(brokerUri);
            var options = new KafkaOptions(uri);
            var router = new BrokerRouter(options);
            var client = new Producer(router);

            while (true)
            {
                var payload = Console.ReadLine();
                if (payload == "exit") break;
                var msg = new Message(payload);                
                client.SendMessageAsync(topicName, new List<Message> { msg }).GetAwaiter().GetResult();
            }
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用系统配置;
使用卡夫卡内;
采用卡夫卡内模型;
使用卡夫卡内协议;
名称空间卡夫卡制作人
{
班级计划
{
静态void Main(字符串[]参数)
{
var brokerUri=ConfigurationManager.AppSettings[“brokerUri”];
Console.WriteLine(“输入要发布到的主题名称”);
var topicName=Console.ReadLine();
Console.WriteLine();
WriteLine($“现在发布到主题{topicName},输入消息,消息之间用回车符分隔”);
Console.WriteLine();
var uri=新uri(brokerUri);
var选项=新卡夫卡选项(uri);
var路由器=新的BrokerOuter(选项);
var客户端=新生产者(路由器);
while(true)
{
var payload=Console.ReadLine();
如果(有效载荷=“退出”)中断;
var msg=新消息(有效负载);
client.SendMessageAsync(topicName,新列表{msg}).GetAwaiter().GetResult();
}
}
}
}

在Kafka中,消息中的时间戳是使用属性message.timestamp.type[CreateTime,LogAppendTime]提供的,该属性可以在生产者级别或主题级别设置

消费者在看到消息时将看到消息时间戳

如果要在生产者级别设置此属性,则需要检查Kafka net API


在Kafka中,消息中的时间戳是使用属性message.timestamp.type[CreateTime,LogAppendTime]提供的,该属性可以在生产者级别或主题级别设置

消费者在看到消息时将看到消息时间戳

如果要在生产者级别设置此属性,则需要检查Kafka net API