bladexboot4集成kafka问题

Blade 未结 0 175
wasiker
wasiker 剑童 2024-07-16 14:07
悬赏:10

一、该问题的重现步骤是什么?


1. bladexboot版本中application-dev中配置kafka


2. kafka地址使用公网地址。


3.

org.springframework.kafkaspring-kafka



spring:

  kafka:

    bootstrap-servers: 公网ip:9092

    consumer:

      group-id: my-consumer-group

      enable-auto-commit: true

      auto-commit-interval: 1000

      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer

      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer

    producer:

      key-serializer: org.apache.kafka.common.serialization.StringSerializer

      value-serializer: org.apache.kafka.common.serialization.StringSerializer

4.配置

package org.springblade.mq;


import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.kafka.core.KafkaTemplate;

import org.springframework.stereotype.Service;


@Service

public class KafkaProducer  {

    private final KafkaTemplate<String, String> kafkaTemplate;


    @Autowired

    public KafkaProducer(KafkaTemplate<String, String> kafkaTemplate) {

       this.kafkaTemplate = kafkaTemplate;

    }


    public void sendMessage(String topic, String message) {

       kafkaTemplate.send(topic, message);

    }

}

package org.springblade.mq;


import lombok.extern.slf4j.Slf4j;

import org.apache.kafka.clients.consumer.ConsumerRecord;

import org.springframework.kafka.annotation.KafkaListener;

import org.springframework.stereotype.Component;


@Component

@Slf4j

public class KafkaConsumer  {

    @KafkaListener(topics = "test-topic", groupId = "test-group")

    public void listen(ConsumerRecord<?, ?> record) {

       log.info("Received message in group test-group: " + record.value());

    }

}

二、你期待的结果是什么?实际看到的又是什么?


        启动项目后,报错。


2024-07-16 05:05:39.851  WARN 9868 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-test-group-1, groupId=test-group] Bootstrap broker localhost:9092 (id: -1 rack: null) disconnected


2024-07-16 05:05:40.751  INFO 9868 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-test-group-1, groupId=test-group] Node -1 disconnected.


2024-07-16 05:05:40.752  WARN 9868 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-test-group-1, groupId=test-group] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.


2024-07-16 05:05:40.752  WARN 9868 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-test-group-1, groupId=test-group] Bootstrap broker localhost:9092 (id: -1 rack: null) disconnected


2024-07-16 05:05:41.189  INFO 9868 --- [ntainer#0-0-C-1] o.a.k.c.c.internals.ConsumerCoordinator  : [Consumer clientId=consumer-test-group-1, groupId=test-group] Resetting generation and member id due to: consumer pro-actively leaving the group


三、你正在使用的是什么产品,什么版本?在什么操作系统上?


       


<artifactId>BladeX-Boot</artifactId>

<packaging>jar</packaging>

<version>4.0.1.RELEASE</version>

四、请提供详细的错误堆栈信息,这很重要。


2024-07-16 05:05:39.851  WARN 9868 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-test-group-1, groupId=test-group] Bootstrap broker localhost:9092 (id: -1 rack: null) disconnected


2024-07-16 05:05:40.751  INFO 9868 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-test-group-1, groupId=test-group] Node -1 disconnected.


2024-07-16 05:05:40.752  WARN 9868 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-test-group-1, groupId=test-group] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.


2024-07-16 05:05:40.752  WARN 9868 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-test-group-1, groupId=test-group] Bootstrap broker localhost:9092 (id: -1 rack: null) disconnected


2024-07-16 05:05:41.189  INFO 9868 --- [ntainer#0-0-C-1] o.a.k.c.c.internals.ConsumerCoordinator  : [Consumer clientId=consumer-test-group-1, groupId=test-group] Resetting generation and member id due to: consumer pro-actively leaving the group


五、若有更多详细信息,请在下面提供。


目前私服上下载的biz工程没有mq-kafka的demo。


回答
  • 消灭零回复
提交回复