Consider the following class :
public class MsgReceiver<MSG> extends AbstractMsgReceiver<MSG> implements
MsgReceiver<MSG> {
@KafkaListener( // necessary properties )
public void receiveMessage(@Headers Map<String, Object> headers, @Payload ConsumerRecord<String,
Object> payload) {
super.receiveMessage(headers,(MSG) (payload.value())); // line foobar
}
The payload.value()
is of type LinkedHashMap
and when I use this class, MSG can be any of my custom POJO class. I get ClassCastException
when converting from LinkedMashMap
to my POJO class on line foobar. How can I resolve this ?