Unable to send data to confluent cloud cluster

I am trying to send a simple text to a cluster I have created in confluent cloud. So I have downloaded config file from cloud with details like username, password, bootstrap server etc. Then I try to send data as

        Properties config = loadCloudConfig("kafka-cloud.properties");
        KafkaProducer<String, String> producer = new KafkaProducer(config);
        ProducerRecord<String, String> record = new ProducerRecord(TOPIC, "First message");
        producer.send(record);
        producer.close();

But I don’t see any data when I check in the topic on cloud, and program logs are as:

[main] INFO org.apache.kafka.common.security.authenticator.AbstractLogin - Successfully logged in.
[main] WARN org.apache.kafka.clients.producer.ProducerConfig - The configuration 'basic.auth.credentials.source' was supplied but isn't a known config.
[main] WARN org.apache.kafka.clients.producer.ProducerConfig - The configuration 'schema.registry.url' was supplied but isn't a known config.
[main] WARN org.apache.kafka.clients.producer.ProducerConfig - The configuration 'basic.auth.user.info' was supplied but isn't a known config.
[main] WARN org.apache.kafka.clients.producer.ProducerConfig - The configuration 'session.timeout.ms' was supplied but isn't a known config.
[main] INFO org.apache.kafka.common.utils.AppInfoParser - Kafka version: 3.1.0
[main] INFO org.apache.kafka.common.utils.AppInfoParser - Kafka commitId: 37ndefd0777bacb3
[main] INFO org.apache.kafka.common.utils.AppInfoParser - Kafka startTimeMs: 1651313288714
[kafka-producer-network-thread | producer-1] INFO org.apache.kafka.clients.Metadata - [Producer clientId=producer-1] Cluster ID: lpd-o22ny7
[main] INFO org.apache.kafka.clients.producer.KafkaProducer - [Producer clientId=producer-1] Closing the Kafka producer with timeoutMillis = 9223372036854775807 ms.
[main] INFO org.apache.kafka.common.metrics.Metrics - Metrics scheduler closed
[main] INFO org.apache.kafka.common.metrics.Metrics - Closing reporter org.apache.kafka.common.metrics.JmxReporter
[main] INFO org.apache.kafka.common.metrics.Metrics - Metrics reporters closed
[main] INFO org.apache.kafka.common.utils.AppInfoParser - App info kafka.producer for producer-1 unregistered

What am I missing here?

Hi @mghildiy The logs don’t provide much clue here :frowning: . It seems to have used the right API key and secret from your config file. Am assuming Topic name, etc are correct. Have you tried debugging on the send() call?

The Kafka API docs show how:

Since the send call is asynchronous it returns a Future for the RecordMetadata that will be assigned to this record. Invoking get() on this future will block until the associated request completes and then return the metadata for the record or throw any exception that occurred while sending the record.
If you want to simulate a simple blocking call you can call the get() method immediately:

 byte[] key = "key".getBytes();
 byte[] value = "value".getBytes();
 ProducerRecord<byte[],byte[]> record = new ProducerRecord<byte[],byte[]>("my-topic", key, value)
 producer.send(record).get();