Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net core 本地:将Kafka与.net core一起使用时主机解析失败_.net Core_Apache Kafka_Message Queue - Fatal编程技术网

.net core 本地:将Kafka与.net core一起使用时主机解析失败

.net core 本地:将Kafka与.net core一起使用时主机解析失败,.net-core,apache-kafka,message-queue,.net Core,Apache Kafka,Message Queue,我对使用Kafka是个新手。我有三台使用Kafka的服务器,希望在我的项目中将它们用作消息代理。他们工作得很好,但突然问题开始出现了。 我尝试使用的代码如下: > using (var adminClient = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = bootStrapServers }).Build()) > { >

我对使用Kafka是个新手。我有三台使用Kafka的服务器,希望在我的项目中将它们用作消息代理。他们工作得很好,但突然问题开始出现了。 我尝试使用的代码如下:

>        using (var adminClient = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = bootStrapServers }).Build())
>                     {
>                         try
>                         {
>                             var topicInfo = adminClient.GetMetadata(topicName, TimeSpan.FromSeconds(10));
>         
>                             
>                             if (topicInfo.Topics.Where(x => x.Error.IsError).Count() == 0)
>                                 await adminClient.DeleteTopicsAsync(new List<string>() { topicName });
>         
>                             await adminClient.CreateTopicsAsync(new TopicSpecification[] {
>                             new TopicSpecification { Name = topicName, ReplicationFactor = 1, NumPartitions = 1 } });
>         
>         
>                         }
>                         catch (CreateTopicsException e)
>                         {
>                             Console.WriteLine($"An error occured creating topic {e.Results[0].Topic}: {e.Results[0].Error.Reason}");
>                         }
>                     }
>使用(var adminClient=new AdminClientBuilder(new AdminClientConfig{bootstrapserver=bootstrapserver}).Build())
>                     {
>试一试
>                         {
>var topicInfo=adminClient.GetMetadata(topicName,TimeSpan.FromSeconds(10));
>         
>                             
>if(topicInfo.Topics.Where(x=>x.Error.IsError.Count()==0)
>等待adminClient.DeleteTopicsAsync(新列表(){topicName});
>         
>等待adminClient.CreateTopicsAsync(新的TopicSpecification[]{
>新的主题规范{Name=topicName,ReplicationFactor=1,NumPartitions=1}});
>         
>         
>                         }
>捕获(CreateTopicsException)
>                         {
>Console.WriteLine($“创建主题{e.Results[0]时出错。主题}:{e.Results[0]。错误。原因}”);
>                         }
>                     }
通过执行这一行代码:

var topicInfo=adminClient.GetMetadata(topicName, 时间跨度从秒(10)开始

每个代理的主机名更改为类似于zk-kafka-test245的内容,brokeroriging属性等于-1,运行时错误为

“本地:主机解析失败”引发