繁体   English   中英

面对原因:org.apache.kafka.clients.consumer.CommitFailedException:

[英]Facing Caused by: org.apache.kafka.clients.consumer.CommitFailedException:

Commit cannot be completed since the group has already rebalanced and assigned the partitions to another member.
    This means that the time between subsequent calls to poll() was longer than the configured max.poll.interval.ms, which typically implies that the poll loop is spending too much time message processing.
    You can address this either by increasing max.poll.interval.ms or by reducing the maximum size of batches returned in poll() with max.poll.records.
java.lang.IllegalStateException: This error handler cannot process 'org.apache.kafka.clients.consumer.CommitFailedException's; no record information is available
    at org.springframework.kafka.listener.DefaultErrorHandler.handleOtherException(DefaultErrorHandler.java:155) ~[spring-kafka-2.8.6.jar:2.8.6]
    at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.handleConsumerException(KafkaMessageListenerContainer.java:1791) [spring-kafka-2.8.6.jar:2.8.6]
    at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.run(KafkaMessageListenerContainer.java:1298) [spring-kafka-2.8.6.jar:2.8.6]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_321]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_321]
    at java.lang.Thread.run(Thread.java:750) [na:1.8.0_321]
Caused by: org.apache.kafka.clients.consumer.CommitFailedException: Commit cannot be completed since the group has already rebalanced and assigned the part

这是生产者和消费者属性。

消费者财产

#set the server port server.port=8004 #Kafka properties spring.kafka.bootstrap-servers=kakfa server instance spring.kafka.properties.security.protocol=SASL_SSL spring.kafka.properties.sasl.mechanism=PLAIN spring.kafka.properties.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule\ \ required username="****" password="****"; spring.kafka.producer.properties.enable.idempotence=false spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer spring.kafka.consumer.value-deserializer= org.springframework.kafka.support.serializer.JsonDeserializer spring.kafka.producer.key-serializer= org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.value-serializer= org.springframework.kafka.support.serializer.JsonSerializer ssl.endpoint.identification.algorithm= spring.kafka.properties.ssl.truststore.type=JKS spring.kafka.properties.ssl.truststore.location=C://Users//Public//Projects//kafka.jks spring.kafka.properties.ssl.truststore.password=**** request.topic=req_topic consumer.group.id=consumer_group_id spring.kafka.consumer.properties.spring.json.trusted.packages=*

生产者属性

#set the server port server.port=8003 #Kafka broker properties spring.kafka.bootstrap-servers=kakfa server instance spring.kafka.properties.security.protocol=SASL_SSL spring.kafka.properties.sasl.mechanism=PLAIN spring.kafka.properties.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule\ \ required username="****" password="****"; spring.kafka.producer.properties.enable.idempotence=false ssl.endpoint.identification.algorithm= spring.kafka.properties.ssl.truststore.type=JKS spring.kafka.properties.ssl.truststore.location=C://Users//Public//Projects//kafka.jks spring.kafka.properties.ssl.truststore.password=**** #Kafka serializers and deserializers spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer spring.kafka.consumer.value-deserializer= org.springframework.kafka.support.serializer.JsonDeserializer spring.kafka.producer.key-serializer= org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.value-serializer= org.springframework.kafka.support.serializer.JsonSerializer #Kafka topic and group configurations request.topic=req_topic response.topic=resp_topic consumer.group.id=consumer_group_id spring.kafka.consumer.properties.spring.json.trusted.packages=*

尝试了以下属性,但仍然面临同样的问题

#Kafka consumer properties #spring.kafka.consumer.properties[request.timeout.ms]=300000 #spring.kafka.consumer.properties[heartbeat.interval.ms]=1000 #spring.kafka.consumer.properties[max.poll.interval.ms]=900000 #spring.kafka.consumer.properties[session.timeout.ms]=600000 #spring.kafka.consumer.properties[max.poll.records]=100

这是我的消费者 class

  @KafkaListener(topics = "${request.topic}", groupId = "${consumer.group.id}", topicPartitions = {
        @TopicPartition(topic = "${request.topic}", partitions = "${partition}") })
    @SendTo
    public String consumer (String message)
    {
       
        return message;
    }

这是我的制片人 class

 @Service public class ProducerService { @Autowired private ReplyingKafkaTemplate<String, String, String> replyingKafkaTemplate; @Value("${request.topic}") String requestTopic; public Object getResponse (Message message) { try { ProducerRecord<String, String> record = new ProducerRecord<>(requestTopic, message); RequestReplyFuture<String, String, String> replyFuture = replyingKafkaTemplate.sendAndReceive(record); ConsumerRecord<String, String> consumerRecord = replyFuture.get(10, TimeUnit.SECONDS); return consumerRecord.value(); } catch (ExecutionException e) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); } catch (InterruptedException e) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); } catch (TimeoutException e) { return ResponseEntity.status(HttpStatus.REQUEST_TIMEOUT).body(e.getMessage()); } catch (Exception e) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Un expected error occured please try again later. "); } }

}

应用程序属性

spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer #spring.kafka.consumer.value-deserializer= org.springframework.kafka.support.serializer.JsonDeserializer spring.kafka.consumer.value-deserializer=org.springframework.kafka.support.serializer.ErrorHandlingDeserializer spring.kafka.consumer.properties.spring.deserializer.value.delegate.class=org.springframework.kafka.support.serializer.JsonDeserializer spring.kafka.producer.key-serializer= org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.value-serializer= org.springframework.kafka.support.serializer.JsonSerializer spring.kafka.consumer.properties.spring.json.trusted.packages=* #spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer #spring.kafka.consumer.value-deserializer= org.springframework.kafka.support.serializer.JsonDeserializer #spring.kafka.producer.key-serializer= org.apache.kafka.common.serialization.StringSerializer #spring.kafka.producer.value-serializer= org.springframework.kafka.support.serializer.JsonSerializer #spring.kafka.consumer.properties.spring.json.trusted.packages=* #spring.kafka.consumer.auto-offset-reset=earliest #spring.kafka.consumer.properties.max.poll.interval.ms=5000000 #spring.kafka.consumer.properties[request.timeout.ms]=300000 #spring.kafka.consumer.properties[heartbeat.interval.ms]=1000 #spring.kafka.consumer.properties[max.poll.interval.ms]=900000 #spring.kafka.consumer.properties[session.timeout.ms]=600000 #Default properties. #request.timeout.ms=30000 #heartbeat.interval.ms=3000 #max.poll.interval.ms=300000 #max.poll.records=500 #session.timeout.ms=45000 #Updated properties. spring.kafka.consumer.properties.request.timeout.ms=300000 spring.kafka.consumer.properties.heartbeat.interval.ms=1000 spring.kafka.consumer.properties.max.poll.interval.ms=600000 spring.kafka.consumer.properties.max.poll.records=100 spring.kafka.consumer.properties.session.timeout.ms=600000 spring.main.allow-circular-references=true spring.kafka.consumer.enable-auto-commit=false spring.kafka.consumer.auto-offset-reset=earliest

错误信息非常清楚。

您的听众处理投票返回的记录的时间过长。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM