当我使用来自 kinesis 流的消息时。我得到一些带有标题等的垃圾字符
@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"));
}
应用 yml
spring:
cloud:
stream:
bindings:
input:
group: abcd
destination: stream
content-type: application/json
errorChannelEnabled: true
consumer:
headerMode: raw
我在侦听器和 errorChannel 都得到了带有垃圾字符的输出
我正在尝试在 errorChannel 中提取原始消息。这是转换字节消息的正确方法吗?
Message recieved: ?contentType "application/json"{"aa":"cc"}