openbmp: Unable to parse Messages
I am consuming messages from the “openbmp.parsed.ls_link” Kafka Topic. I am facing difficulty in unwrapping the messages that i am recieving from the topic. I have the option of recieving the messages as of type Object or as type org.springframework.messaging.Message. I tried parsing the payload in both cases by casting to the type org.openbmp.handler.LsLink. But what i got was a classcastexception. I have referred to the link http://www.openbmp.org/#!docs/MESSAGE_BUS_API.md for a description of the message attributes. But i am unable to obtain the individual attributes from the object that i am recieving when reading messages from the mentioned topic. Please guide if possible with code example as to how i can parse the messages. My code for reading messages from the topic is like this.
@EnableBinding(Sink.class) public class CloudStreamConsumer {
private static Logger logger = LoggerFactory
.getLogger(CloudStreamConsumer.class);
/**
* Method that receives the Kafka message
* @param payload
* @throws Exception
*/
@ServiceActivator(inputChannel = Sink.INPUT)
//@StreamListener(Sink.INPUT)
public void logger(Message<?> payload) throws Exception {
//logger.info("recieved : " + payload);
logger.info("Recieved Payload : " + payload.getPayload());
logger.info("Recieved Headers : " + payload.getHeaders());
LsLink pbj = (LsLink)payload.getPayload();
logger.info("Obj = " + pbj.toString());
}
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22 (10 by maintainers)
I tried searching in github “openbmpd” but could not find any repo of that name. I am consuming messages from the topic “openbmp.parsed.ls_link”. I have access to only this topic. I dont have control of the messages that are getting sent to this topic. Please provide more details on what i need to do to parse messages correctly.