java Spring集成错误/异常处理

fdx2calv  于 2023-02-07  发布在  Java
关注(0)|答案(1)|浏览(114)

我已经开始使用Spring Integration使用Spring Integration Google发布/订阅模型向外部系统发送消息。
我正在发送由服务激活器接收的有效负载,如下所示

@ServiceActivator(inputChannel = "inputChannel")
              public void messageReceiver(final String payloadMessage) throws IOException {
    adapter.sendData(payloadMessage);  // send payloadMessage data to external system, add exception handlers
}

我想要的是对适配器.sendData(payloadMessage)实现异常处理,这样我就可以考虑各种场景,如
1.外部系统关闭
1.从我的系统连接到外部系统的网络问题。
我一直在遵循以下Google云文档和其他在线文档,但没有找到足够的用例来处理上述场景https://cloud.google.com/pubsub/docs/spring#using-spring-integration-channel-adapters
考虑到上述场景,我希望以这样一种方式实现异常处理,即当出现异常时数据不会丢失,并且即使在一段时间后出现异常,外部系统也应该接收数据。

qv7cva1a

qv7cva1a1#

听起来您需要一些围绕异常的重试和回退逻辑。
更多信息请参见文档:www.example.com网站。https://docs.spring.io/spring-integration/reference/html/messaging-endpoints.html#message-handler-advice-chain.
@ServiceActivator具有adviceChain属性供您考虑。

相关问题