When I consume the message from kinesis stream. I get some junk chars with headers etc
@StreamListener(Processor.INPUT)
public void receive(String message) {
System.out.println("Message recieved: "+message);
throw new RuntimeException("Exception thrown");
}
@StreamListener("errorChannel")
public void transform(ErrorMessage errorMessage) throws UnsupportedEncodingException {
//original paylaod
System.out.println("Error Oiginal Message Payload"+new String((byte[])errorMessage.getOriginalMessage().getPayload(), "UTF-8"));
System.out.println("Error Original Message Stream channel"+errorMessage.getOriginalMessage().getHeaders().get("aws_receivedStream"));
}
Aplication yml
spring:
cloud:
stream:
bindings:
input:
group: abcd
destination: stream
content-type: application/json
errorChannelEnabled: true
consumer:
headerMode: raw
I get output at the both the listener and errorChannel with junk characters
I am trying to extract the original message in errorChannel . Is this the right way to convert the bytes message?
Message recieved: ?contentType "application/json"{"aa":"cc"}