8

EVEN DRIVEN - SPRING CLOUD STREAM - Error Handling - paulwong - BlogJava

 2 years ago
source link: http://www.blogjava.net/paulwong/archive/2021/11/17/436052.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

EVEN DRIVEN - SPRING CLOUD STREAM - Error Handling

如果Function中抛出异常,系统没有配置捕获异常,则异常消息会被丢弃。通常会进行配置。
@ServiceActivator(inputChannel = "my-destination.my-group.errors")
    public void handleError(ErrorMessage message) {
        Throwable throwable = message.getPayload();
        log.error("截获异常", throwable);

Message<?> originalMessage = message.getOriginalMessage();
        assert originalMessage != null;

log.info("原始消息体 = {}", new String((byte[]) originalMessage.getPayload()));
    }
详情参考:
https://www.itmuch.com/spring-cloud/spring-cloud-stream-error-handling/

posted on 2021-11-17 10:50 paulwong 阅读(9) 评论(0)  编辑  收藏 所属分类: SPRING CLOUDEVEN DRIVEN ARCHITECT


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK