How pass data from feeder into Kafka message?

77 Views Asked by At

I am trying to scenario when data is taken from feed and passed to Kafka topic with usage of Gatling and existing plugging for Kafka.

    public static ScenarioBuilder kafkaScenario() {
        FeederBuilder.FileBased<Object> random = CoreDsl.jsonFile("requests.json").random();
        return CoreDsl.scenario("A")
                .feed(random)
                .exec(kafka("kafka request")
                        .send("test", "#{host}"));
    }

    
    
    public static ScenarioBuilder httpScenario() {
        FeederBuilder.FileBased<Object> random = CoreDsl.jsonFile("requests.json").random();
        return CoreDsl.scenario("B")
                .feed(random)
                .exec(http("http request")
                        .get("/register?host=#{host}")
                        .check(jmesPath("id").saveAs("usernameRsp")))
                .exec(session -> {
                    System.out.println("response: " + session.get("patientIdRsp"));
                    return session;
                });
    }

In order to access value from feed I use ${host} but on consumer side it just receives ${host} as message instead of expected values top1, top2 or top3.

The output in first exec shows different values of host.

UPD: I've tried to make same with http so it works well and host value is passed from the file.

UPD 2: The send method implementation uses inside toStaticValueExpression what makes it not working properly, when changing it to toStringExpression it works well for a case describe above.

What's wrong in this code for Kafka scenario? Thanks!

0

There are 0 best solutions below