0

I'm getting a compilation error when trying to create a new topic with KafkaStream object.

My new topic should contain a key and a value which is an Array. Here is my code :

  Serde<String> stringSerde = Serdes.String();   
 // Cannot create a Serde of  an ArrayList
  Serde<String> arrayListSerde = Serdes.String();     
  KStream<String, String> stats = builder.stream("parking-rows-stats"); 

  KStream<String, List<String>> parkingCountAndTypeStream = stats                                                
            .selectKey((key, jsonRecordString) -> extractParkingName(jsonRecordString))                            
            .map((key, value) -> new KeyValue<>(key, extractPlaceTypeAndNumber(value))); 
  //Compilation error in this line               
  parkingCountAndTypeStream.to("parking-typeandnbfreeplaces-updates", Produced.with(stringSerde,arrayListSerde));
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Anas Hadhri
  • 159
  • 1
  • 2
  • 9
  • Have you tried using the serdes from here https://stackoverflow.com/questions/46365884/issue-with-arraylist-serde-in-kafka-streams-api – Irshad P I Dec 30 '19 at 20:04
  • 1
    What is the error you're getting? Does it say you have a `Serde`, not `Serde>`. Also, why not convert your values into a `JsonArray` that you can use with StringSerializer? – OneCricketeer Dec 31 '19 at 03:36
  • I want to have a key with 2 corresponding value , can you put in responses another solution please? – Anas Hadhri Dec 31 '19 at 09:19

0 Answers0