cancel
Showing results for 
Search instead for 
Did you mean: 

Properties props = new Properties staying null in groovy script

Highlighted
Occasional Contributor

Properties props = new Properties staying null in groovy script

I'm trying to connect to KAFKA via groovy and use a widely popular script However, props is continuously returning null. I have tried both props.setProperty and props.put alike. Neither works, and props stays null of size 0. Script is below:

 

Properties props = new Properties();
props.setProperty("bootstrap.servers", "localhost:9092")
props.setProperty("group.id", "test")
props.put("enable.auto.commit", "true");
props.put("auto.commit.interval.ms", "1000");
props.put("key.deserializer","org.apache.kafka.common.serialization.StringDeserializer");
props.put("value.deserializer","org.apache.kafka.common.serialization.StringDeserializer");
KafkaConsumer<String, String> consumer = new KafkaConsumer<String, String>(props);

2 REPLIES 2
Highlighted
Community Manager

Re: Properties props = new Properties staying null in groovy script

Hi @dvictor, I found an article that might help: https://stackoverflow.com/questions/60433565/calling-getproperty-on-a-properties-instance-is-returni...  


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Occasional Contributor

Re: Properties props = new Properties staying null in groovy script

Hi @sonya_m thanks for your response.

 

I have tried using both props.put("A", "B") and props.setProperty("A", "B") to no avail. 

 

Regardless of which method is used, when I go to load props into the linke of code below, props is still null with size of 0.

  • KafkaConsumer<String, String> consumer = new KafkaConsumer<String, String>(props);
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors