无法将消息发布到kafka

时间:2019-04-13 04:17:00

标签: java spring apache-kafka kafka-producer-api spring-kafka

我需要将两个事件推送到kafka。我能够推送一个。我在推第二个时遇到了算术异常。我正在使用spring-Kafka。

   public Map<String, Object> producerConfigs() {
        Map<String, Object> props = new HashMap<>();
        // list of host:port pairs used for establishing the initial connections to the Kakfa cluster
        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
        props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
        props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class);
        return props;
    }

//sending using kafka-template
kafkaTemplate.send(subscriptionTopic, subscriptionEvent);


2019-04-13 09:39:49:189 [kafka-producer-network-thread | producer-1] [/] ERROR org.apache.kafka.clients.producer.internals.Sender:164 - Uncaught error in kafka producer I/O thread: 
java.lang.ArithmeticException: / by zero
    at org.apache.kafka.clients.producer.internals.RecordAccumulator.drain(RecordAccumulator.java:438) ~[kafka-clients-0.11.0.2.jar:?]
    at org.apache.kafka.clients.producer.internals.Sender.sendProducerData(Sender.java:254) ~[kafka-clients-0.11.0.2.jar:?]
    at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:223) ~[kafka-clients-0.11.0.2.jar:?]
    at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:162) [kafka-clients-0.11.0.2.jar:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]

异常不断出现。...就像在循环中一样

0 个答案:

没有答案