Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

FailedToSendMessageException when RequiredAcks != 0 #78

@jbrestan

Description

@jbrestan

Hi everyone,

I'm using CSharpClient-for-Kafka NuGet 1.0.47 against Kafka 0.9.0.1 to implement a simple producer.

Every time I try to send a message with non-default ProducerConfiguration.RequiredAcks, the client fails after 3 attempts with FailedToSendMessageException.
Interesting fact is that the message is actually delivered to the broker three times, and even passed to the consumers three times. When I don't use any acknowledgements, sending message works perfectly fine, but for my use case I need delivery guarantees, so RequiredAcks=0 is not really an option.

I've tried using the Kafka built-in kafka-console-producer.sh and it works as expected even with --request-required-acks set to 1 or -1 - the message is delivered once and with no error.

This leads me to believe there's either an issue with the Producer (not processing acks correctly?) or the way I'm using it.

The topic has 5 partitions on 2 brokers, replication factor 1.

My code to reproduce:

var brokers = new[] { ... };    
var config = new ProducerConfiguration(brokers){RequiredAcks=1};
var producer = new Producer(config);
var message= new Message(Encoding.UTF8.GetBytes("Hi from C#"));
var batch = new ProducerData<string, Message>("test", "key", message);
producer.Send(batch);

The exception thrown on producer.Send:

Failed to send messages after 3 tries. FailedProducerDatas not empty. Success Count:0 Failed Count: 1.
================Failed sent message key: Topic: test Key: key
================Failed Detail: Broker:0,Topic:test PartitionID:1,Error:UnknownCode Offset:-1

Stack trace:

   at Kafka.Client.Producers.DefaultCallbackHandler`2.Handle(IEnumerable`1 events)
   at Kafka.Client.Producers.Producer`2.Send(IEnumerable`1 data)
   at Kafka.Client.Producers.Producer`2.Send(ProducerData`2 data)

kafka-console-consumer.sh output after a single call:

Hi from C#
Hi from C#
Hi from C#

Thank you for any advice!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions