Can not connect to Confluence Cloud topic from Java Springboot client

Hi all.

I’m new in Confluent Cloud and I’m trying to send a simple event from a Java Spring Boot client to a Confluent Cloud topic. I saw some tutorial from Confluent site and some source code from github, however I can’t get it to work.

I always receive a log message like this:

org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Bootstrap broker (id: -1 rack: null) disconnected

My is: required username='<API KEY>' password='<API SECRET>';

And my Kafka configuration class is:


public class KafkaConfiguration {
  Logger log = LoggerFactory. *getLogger* (getClass());
  private Environment env;

    public ProducerFactory<Integer, String> producerFactory() {
      String kafkaServer = env.getProperty("");"Kafka Server: " + kafkaServer);
      return  new DefaultKafkaProducerFactory<>(Map.of (
        BOOTSTRAP_SERVERS_CONFIG, kafkaServer,
        RETRIES_CONFIG , 0,
        BATCH_SIZE_CONFIG , 16384,
        LINGER_MS_CONFIG , 1,
        BUFFER_MEMORY_CONFIG , 33554432,
        KEY_SERIALIZER_CLASS_CONFIG, IntegerSerializer.class,
        VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class)


 public KafkaTemplate<Integer, String> kafkaTemplate() {
    return new KafkaTemplate<>(producerFactory());

Finaly, this is the producer class:


class Producer {


  private KafkaTemplate<Integer, String> template;

  Faker faker;


  public void generate() {

     faker = Faker.instance();

      final Flux<Long> interval = Flux.interval(Duration.ofMillis (1_000));

      final Flux<String> quotes = Flux.fromStream(Stream.generate(() -> faker.hobbit().quote()));, quotes)
         .map(it -> template.send("test", faker.random().nextInt(42), it.getT2())).blockLast();

I appreciate your help with this.

have you tried with setting this property?


1 Like

Here is my working config file.

bootstrap.servers=<ccloud kafka>:9092
sasl.mechanism=PLAIN required username="<USER>" password="<PASSWORD >";
1 Like