我有一条骆驼路线,它会自称直到满足特定条件。基本上,这个想法是实现路由重试。部署应用程序时,如果重试时间很长,则会收到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错误是由于route的递归调用引起的,我更改了路由结构,现在重新交付由骆驼onException()中可用的retryDelivery机制处理。在条件满足之前,我的重试次数可以是无限的。

我需要知道这种方法再次出现stackOverFlow的机会。

最佳答案

不,这是使用onException和其他错误处理功能来处理错误处理重新交付的正确方法。使用循环EIP会导致更长的堆栈帧,因此不应将其用于循环时间过长的情况。所以您做了正确的修复。

关于java - camel:递归调用路由时,stackoverflow错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51257248/

10-14 11:31