java - Camel : stackoverflow error when route is called recursively

标签 java apache apache-camel

我有一条 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/

相关文章:

java - 是否可以将 CamelContext 的 ShutdownStrategy 外包到中央 OSGi 包中?

java - 使用apache-camel多播将一个文件上传到不同位置

java - 使用exe文件保护Jar文件源代码(Java)

apache - 将 apache 设置为 nodejs 应用程序的别名?

java - Apache Camel : What is the best way to reuse Camel routes from other routes?

apache - 调整 AWS Apache 服务器

python - 使用 mod_rewrite 隐藏在 Web 浏览器上访问的 Python 脚本的 .py 扩展名

java - 无法解释的 NoClassDefFoundError 异常

java - Referer header 中的 URL 被检测为使用多种编码

Java JProgressBar不会绘制消耗值