All Products
Search
Document Center

ApsaraMQ for Kafka:How do I determine whether a message is sent from the client?

Last Updated:Mar 11, 2026

When a Kafka producer calls send(), most client libraries return a callback or a future. If the callback succeeds or the Future completes without an exception, the message is sent.

Verify delivery in your producer code

Inspect the result returned by send() to confirm delivery. The following Java example uses a Callback to check whether the broker acknowledged the write:

producer.send(new ProducerRecord<>(topic, key, value), (metadata, exception) -> {
    if (exception != null) {
        // Send failed -- log the error and handle the retry
        exception.printStackTrace();
    } else {
        // Send succeeded -- metadata contains the target partition and offset
        System.out.printf("Message delivered: topic=%s, partition=%d, offset=%d%n",
                metadata.topic(), metadata.partition(), metadata.offset());
    }
});

A successful callback confirms the broker acknowledged the write. The exact guarantee depends on the acks producer setting:

acks valueSuccessful callback meaning
0The message was sent over the network. The broker did not confirm receipt.
1The partition leader wrote the message to its local log.
all (default)The partition leader and all in-sync replicas acknowledged the message. This is the strongest durability guarantee.
With acks=0, a successful callback does not guarantee the broker received the message. For production workloads, keep the default acks=all for the strongest durability guarantee.

Verify delivery in the ApsaraMQ for Kafka console

You can also use the following methods to check whether a message is sent as expected in the ApsaraMQ for Kafka console:

  • Check partition status -- Open the Topic Details page and go to the Partition Status tab. This tab shows the number of messages in each partition in real time. An increase in the message count confirms the producer is writing to the topic. For details, see View partition status.

  • Check traffic charts -- On the same Topic Details page, go to the CloudMonitor tab. The traffic charts display throughput at per-minute intervals. A visible uptick after you start the producer confirms messages are arriving at the broker.