influxdata / rskafka

A minimal Rust client for Apache Kafka
Apache License 2.0
292 stars 33 forks source link

Production message error: Client(Request(NoVersionMatch { api_key: Produce })) #235

Closed rollbor closed 6 months ago

rollbor commented 6 months ago

Hello, I have had some problems using this crate recently, I would like to ask you to help take a look, thank you very much! Appreciate!!!

Error details log

thread 'tokio-runtime-worker' panicked at 'produce error:: Client(Request(NoVersionMatch { api_key: Produce }))', src\main.rs:110:44

Environment in

Execute the command

   cargo run

Source

async fn test_batch_producer() {
    let connection = "127.0.0.1:9092".to_owned();
    let client = ClientBuilder::new(vec![connection]).build().await.unwrap();
    let topic = "test";
    // produce some data
    let record = Record {
        key: Option::from(b"".to_vec()),
        value: Option::from(b"hello kafka".to_vec()),
        headers: Default::default(),
        timestamp: Default::default(),
    };

    let partition_client = Arc::new(
        client
            .partition_client(&*topic, 0, UnknownTopicHandling::Retry)
            .await
            .unwrap(),
    );
    let producer = BatchProducerBuilder::new(partition_client)
        .with_linger(Duration::from_secs(5))
        .build(RecordAggregator::new(record.approximate_size() * 2 + 1));
    producer.produce(record.clone()).await.expect("produce error: ");
}
crepererum commented 6 months ago

rskafka doesn't support old Kafka versions, mostly because the complexity of protocol becomes a too high.