Toerktumlare
Toerktumlare
JCHJava Community | Help. Code. Learn.
Created by 40г белка on 9/20/2024 in #java-help
Need help w init kafka consumer (have an error w listenner)
I hope thats enough for you to get it working
9 replies
JCHJava Community | Help. Code. Learn.
Created by 40г белка on 9/20/2024 in #java-help
Need help w init kafka consumer (have an error w listenner)
Kafka per default sends Strings, it cant handle anything else. So if you say you are sending an Object, it will per default send a string. If you on the other hand define KafkaTemplate<String, CommentEvent> kafka will still send it as a string but also include type information in one of its headers so the consumers know what to deserialize the string into. Also if you define the correct type, the consumer will prolly still not work as you have to define in the consumer JsonDeserializer.TRUSTED_PACKAGES in the consumer configuration options. Which is a security feature. That is there to prevent an unknown producer to produce a malicious string, and then provide malicious type information to tell the consumer to consume the string and deserialize it into some class that will perform code execution on this random malicious string. If you know that you will not have any unknown producers, then you can disable this security feature by setting props.put(JsonDeserializer.TRUSTED_PACKAGES, "*"); in your consumer config. This says that we trust ever event that comes. In an enterprise environment, you have a shared library that contains the Event class that both the producer and consumer includes so they have the exact same object on both sides and then you define its package as trusted.
9 replies
JCHJava Community | Help. Code. Learn.
Created by 40г белка on 9/20/2024 in #java-help
Need help w init kafka consumer (have an error w listenner)
KafkaTemplate<String, Object>
9 replies
JCHJava Community | Help. Code. Learn.
Created by 40г белка on 9/20/2024 in #java-help
Need help w init kafka consumer (have an error w listenner)
why have you defined Object in the KafkaTemplate
9 replies