gatling-kafka-plugin icon indicating copy to clipboard operation
gatling-kafka-plugin copied to clipboard

Kafka header from feeder

Open Killen911 opened this issue 2 years ago • 3 comments

Hi. Is possible to send kafka headers from feeder in this plugin? Need something like this: .exec(kafka("my-topic").send[String,String]("{ \"kafka\": \"message\"", session => session("headers")))

Killen911 avatar Nov 30 '22 08:11 Killen911

It's possible to set a header from a session parameter like this

   .exec(s => s.set("custom", new RecordHeaders().add("test-header", s("kekey").as[Array[Byte]])))
   .exec(
      kafka("BasicRequest")
        .send[String, String]("foo", "foo", "#{custom}"),
    )```

3alster avatar Feb 06 '23 13:02 3alster

@3alster I tried as suggested in Java, but I am getting error as header is in string , expected is 'Header' format

WhatsApp Image 2023-06-14 at 15 16 39

partheebanMani avatar Jun 14 '23 10:06 partheebanMani

Hi @partheebanMani, that's because you mixed up the types, just use RecordHeaders type instead of the Session for the headers variable.

3alster avatar Jul 06 '23 21:07 3alster