代码如下

 public static void producer1() throws ExecutionException, InterruptedException {
Properties props = new Properties();
props.put("bootstrap.servers", "xxx:9092,xxx:9092,xxx:9092");
props.put("zookeeper.connect", "xxx:2181,xxx:2181,xxx:2181");
props.put("acks", "all");
props.put("retries", );
props.put("batch.size", );
props.put("linger.ms", );
props.put("buffer.memory", );
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); Producer<String, String> producer = new KafkaProducer<String, String>(props);
for (int i = ; i < ; i++) {
System.out.println(i);
Future<RecordMetadata> future = producer.send(new ProducerRecord<String, String>("topic_test_1219", Integer.toString(i), Integer.toString(i)));
System.out.println("partiton:" + future.get().partition() + ",offset:" + future.get().offset() + ",isDone:" + future.isDone());
}
producer.close();
}

错误如下

Exception in thread "main" java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for topic_test_1219-2: 30010 ms has passed since batch creation plus linger time
at org.apache.kafka.clients.producer.internals.FutureRecordMetadata.valueOrError(FutureRecordMetadata.java:94)
at org.apache.kafka.clients.producer.internals.FutureRecordMetadata.get(FutureRecordMetadata.java:64)
at org.apache.kafka.clients.producer.internals.FutureRecordMetadata.get(FutureRecordMetadata.java:29)
at com.zhen.kafka.ProducerTest.producer1(ProducerTest.java:38)
at com.zhen.kafka.ProducerTest.main(ProducerTest.java:18)
Caused by: org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for topic_test_1219-2: 30010 ms has passed since batch creation plus linger time

  折腾许久,原来是域名解析问题,记得本地hosts中配一下kafka服务所在机器的IP

Exception in thread "main" java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for topic_test_1219-2: 30010 ms has passed since batch creatio的更多相关文章

  1. The main method caused an error: java.util.concurrent.ExecutionException: org.apache.flink.runtime.client.JobSubmissionException: Failed to submit JobGraph.

    在使用flink run命令提交任务可能会遇到如下错误: The program finished with the following exception: org.apache.flink.cli ...

  2. Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 0 [ ^

    Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character clas ...

  3. Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 0 解决方法: 要对切割字符进行转义\\

    使用str.split("[",15)时,出现Exception in thread "main" java.util.regex.PatternSyntaxE ...

  4. Exception in thread "main" java.util.ConcurrentModificationException解决方案

    我想判断一个集合里面有没有"world"这个元素,如果有,我就添加一个"javaee"元素, 当时的做法是: public class ListIterator ...

  5. java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]

    本文为博主原创,未经允许不得转载: 被坑了好长时间的bug,差点就要重新配置环境,重新下载,重新开始的境遇.在此记录一下: 首先展示一下报错的异常: -Apr- ::] org.apache.cata ...

  6. java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/xiaozao_web]]

    二月 20, 2017 11:30:28 上午 org.apache.tomcat.util.digester.SetPropertiesRule begin警告: [SetPropertiesRul ...

  7. java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException or 程序包 javax.servlet 不存在

    遇到下面这个问题 程序包 javax.servlet 不存在 或者 java.util.concurrent.ExecutionException: org.apache.catalina.Lifec ...

  8. 严重: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component

    自己写了个最简单的springMVC项目练练手,没有用maven,在WebContent中新建了lib文件夹,将jar包复制到这里面,然后add to build path到项目里. 启动Tomcat ...

  9. java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component...

    今天开发犯了一个特lowB的错,记录下来,引以为戒! 严重: A child container failed during start java.util.concurrent.ExecutionE ...

随机推荐

  1. 复制对象(一)copy和mutableCopy方法

    本文转载至 http://www.tuicool.com/articles/Fn6rMn CSDN博客原文  http://blog.csdn.net/u010962810/article/detai ...

  2. EasyNVR和EasyDSS云平台联手都不能解决的事情,只有国标GB28181能解决了

    需求痛点 我们经常收到这样一种需求,就是将客户手里的各种类型的网络摄像机IPC和网络硬盘录像机NVR进行统一的整合接入和管理,并进行常规的直播.存储.录像检索和回放等操作,而这个时候我们通常会选择用E ...

  3. bfs_迷宫求最短路径

    宽度优先搜索按照距离开始状态由近及远的顺序进行搜索,可以很容易用来求解最短路径或者最少操作等问题. 将已经访问过的状态用标记管理起来,便可以很好地做到由近及远的搜索. import java.util ...

  4. django database relations

    注意Django的生成的默认api from django.db import models class Place(models.Model): ''' pass class Restaurant( ...

  5. Unit redis-server.service is masked.

    http://stackoverflow.com/questions/40317106/failed-to-start-redis-service-unit-redis-server-service- ...

  6. Centos中查询目录中内容命名ls(六)

    首先解释下这块, root代表当前登录用户,localhost代表主机名, ~代表当前主机目录,#代表用户权限 #表示超级用户,$表示普通用户: 查询目录中内容命令 ls  (list缩写) 格式 l ...

  7. 高德地图API使用

    1.根据地址找经纬度/修改经纬度 marker.setPosition(result.geocodes[0].location); map.setCenter(marker.getPosition() ...

  8. element-UI的操作步骤steps每一项添加事件,比如click,hover

    简单来说,只添加click 和css :hover就好了 一.组件里 <el-steps :space="200" :active="1" finish- ...

  9. 什么是PHP闭包???

    闭包函数:临时创建一个没有名称的函数,经常作为回调函数来用. 通俗的说就是:子函数可以使用父函数中的局部变量,这种行为叫做闭包. 1.匿名函数赋值 $demo=function($str){ echo ...

  10. locust参数化

    前面用篇专门讲了requests实现接口的参数关联案例,这里直接转化成locust脚本就行了 # coding:utf-8 from locust import HttpLocust, TaskSet ...