gpt4 book ai didi

java - Camel : stackoverflow error when route is called recursively

转载 作者:行者123 更新时间:2023-12-02 11:02:07 26 4
gpt4 key购买 nike

我有一条 Camel 路线,它会 self 调用,直到满足特定条件为止。基本上的想法是实现路由重试。部署应用程序后,如果长时间重试,我会收到 stackoverflow 错误。

    [Camel (camel-1) thread #1 - Multicast] ERROR com.application.RouteName.lambda$configure$0 - Exception occurred during execution on the exchange: Exchange[ID-batchrater-310822922-1-383133832-34058-1530798326741-0-6]
org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-batchrater-310822922-1-383133832-34058-1530798326741-0-6]
at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1779)
at org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:351)

.
.
.
.
Caused by: java.lang.StackOverflowError: null
at org.springframework.beans.factory.support.AbstractBeanFactory.transformedBeanName(AbstractBeanFactory.java:1117)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:239)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1084)
at org.apache.camel.spring.spi.ApplicationContextRegistry.lookupByNameAndType(ApplicationContextRegistry.java:47)
at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookupByNameAndType(PropertyPlaceholderDelegateRegistry.java:63)
at org.apache.camel.component.bean.BeanInfo.createParameterMappingStrategy(BeanInfo.java:177)
at org.apache.camel.component.bean.BeanInfo.<init>(BeanInfo.java:99)

我相信 stackoverflow 错误是由于路由的递归调用造成的,我更改了路由结构,现在重新传递由camel onException() 中可用的 retryDelivery 机制处理。而且我的重试次数可以是无限的,直到满足条件为止。

我需要知道采用这种方法是否有可能再次出现 stackOverFlow

最佳答案

不,这是使用 onException 和其他错误处理功能来处理错误处理重新传递的正确方法。使用循环 EIP 会导致堆栈帧更长,因此不应该用于太长的循环。所以你做了正确的修复。

关于java - Camel : stackoverflow error when route is called recursively,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51257248/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com