kafka.common.KafkaException: Wrong request type 18
模拟配置kafka服务器后用简单的java客户端发送消息但是不见消息储存一直只能看到这个报错日志(消息确实没有储存)
kafka.common.KafkaException: Wrong request type 18
at kafka.api.RequestKeys$.deserializerForKey(RequestKeys.scala:64)
at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:50)
at kafka.network.Processor.read(SocketServer.scala:450)
at kafka.network.Processor.run(SocketServer.scala:340)
at java.lang.Thread.run(Thread.java:745)
[2018-03-24 11:12:14,032] ERROR Closing socket for /192.168.23.1 because of error (kafka.network.Processor)
kafka.common.KafkaException: Wrong request type 18
at kafka.api.RequestKeys$.deserializerForKey(RequestKeys.scala:64)
at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:50)
at kafka.network.Processor.read(SocketServer.scala:450)
at kafka.network.Processor.run(SocketServer.scala:340)
at java.lang.Thread.run(Thread.java:745)
[2018-03-24 11:12:14,087] ERROR Closing socket for /192.168.23.1 because of error (kafka.network.Processor)
kafka.common.KafkaException: Wrong request type 18
at kafka.api.RequestKeys$.deserializerForKey(RequestKeys.scala:64)
at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:50)
at kafka.network.Processor.read(SocketServer.scala:450)
at kafka.network.Processor.run(SocketServer.scala:340)
at java.lang.Thread.run(Thread.java:745)
[2018-03-24 11:12:14,140] ERROR Closing socket for /192.168.23.1 because of error (kafka.network.Processor)
kafka.common.KafkaException: Wrong request type 18
at kafka.api.RequestKeys$.deserializerForKey(RequestKeys.scala:64)
at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:50)
at kafka.network.Processor.read(SocketServer.scala:450)
at kafka.network.Processor.run(SocketServer.scala:340)
at java.lang.Thread.run(Thread.java:745)
[2018-03-24 11:12:14,244] ERROR Closing socket for /192.168.23.1 because of error (kafka.network.Processor)
kafka.common.KafkaException: Wrong request type 18
at kafka.api.RequestKeys$.deserializerForKey(RequestKeys.scala:64)
at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:50)
at kafka.network.Processor.read(SocketServer.scala:450)
at kafka.network.Processor.run(SocketServer.scala:340)
at java.lang.Thread.run(Thread.java:745)
毕竟是java客户端写了死循环输出消息所以多余重复的日志就不多写了
小弟个人觉得是zookeeper这里或是kafka这里设置的消息大小有问题,但是确实不知道改哪里,求大神指导
下面是简易java客户端的代码
···java
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import java.util.Properties;
public class ProducerTest {
public static void main(String[] args) {
//todo:1、配置文件
Properties props = new Properties();
props.put("bootstrap.servers","node1:9092");
props.put("acks","all");
props.put("retries",0);
props.put("batch.size",16384);
props.put("linger.ms",1);
props.put("buffer.memory",33554432);
props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer","org.apache.kafka.common.serialization.StringSerializer");
//todo:2、创建kafkaProducer
KafkaProducer<String,String> kafkaProducer = new KafkaProducer<String,String>(props);
for (int i = 0; i <100; i++){
//todo:3、发送数据给kafka
kafkaProducer.send(new ProducerRecord<String, String>
("test","sdfafasdgfak",
"Consumer Group(dfsadfa fasfasfasefawe4fawefawe fawef awfa)"));
}
}
}
···
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题是由于你服务器上的kafka版本和你代码中配置的kafka版本不一致导致的,比如你服务器上部署的是2.1.10 这个对应你本地开发环境中maven中kafka的版本号是0.8.10 但是你开发的时候用的却是2.1.12 这样就会出现这个问题