Forum Discussion

Markus_F's avatar
Markus_F
Occasional Contributor
6 years ago

Apache Kafka consumer in SOAPUI pro

Hi,

 

Can anyone help me in recording and asserting the data from a kafka producer application in SOAPUI Pro?

I tried with groovy script and example code from the apache website but I was not successful yet.

 

Thanky in advance.

 

Regards

Markus

 

    • Markus_F's avatar
      Markus_F
      Occasional Contributor

      I get too many errors, therefore this seems for me be not straight forward.

       

      The example code is:

           Properties props = new Properties();
           props.setProperty("bootstrap.servers", "localhost:9092");
           props.setProperty("group.id", "test");
           props.setProperty("enable.auto.commit", "true");
           props.setProperty("auto.commit.interval.ms", "1000");
           props.setProperty("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
           props.setProperty("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
           KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
           consumer.subscribe(Arrays.asList("foo", "bar"));
           while (true) {
               ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
               for (ConsumerRecord<String, String> record : records)
                   System.out.printf("offset = %d, key = %s, value = %s%n", record.offset(), record.key(), record.value());
           }

       

      Do you know what to add into the lace braces instead of "String, String"?

      KafkaConsumer<String, String>

      ConsumerRecords<String, String>