返回到文章

采纳

编辑于
liu

生产者推送消息,为什么TASK状态一直是WaitingForActivation?

kafka

生产者推送消息,为什么TASK状态一直是WaitingForActivation?

.NET

protected async Task PushSummaryData(string data, Item v)
        {
            var config = new Dictionary<string, object>
            {
                {"bootstrap.servers",v.kafka.BootstrapServers}
            };

            using (var p = new Producer<Null, string>(config, null, new StringSerializer(Encoding.UTF8)))
            {
                try
                {
                    WLog.WriteLog("UnitDataPush", "数据正在发送!");
                    var dr = await p.ProduceAsync(v.kafka.Topic, null, data);
                    WLog.WriteLog("UnitDataPush", dr.Error.Code.ToString());
                }
                catch (KafkaException e)
                {
                    WLog.WriteLog("UnitDataPush", e.Error.Reason);
                }
            }
     }