我有一条小路线,我想使用自定义的重新传递策略来重复向endpoint发送消息,但这种行为非常奇怪。看起来,重新交付政策只是在重复一个错误。我试图将所有交换发送到路由的开头,但策略不起作用,因为每次都在创建:
<route id="sampleRoute">
<from uri="direct:anotheRoute" />
<to uri="nmr:kaboom" />
<choice>
<when>
<xpath>//result = 'true'</xpath>
<to uri="direct:anotherAnotherRoute" />
</when>
<otherwise>
<throwException ref="redeliveryException" />
</otherwise>
</choice>
<onException>
<exception>java.net.SocketException</exception>
<exception>java.net.ConnectException</exception>
<exception>my.custom.error.RedeliveryException</exception>
<redeliveryPolicy ref="customRedeliveryPolicy" />
<to uri="direct:anotheRoute" />
</onException>
</route>
我做错了什么?当错误发生时,我想以间隔重复我的请求。我的骆驼版本是2.6
日志:
16:29:43,780 | DEBUG | cc5bd91-thread-1 | DefaultListableBeanFactory | | 59 - org.springframework.beans - 3.0.5.RELEASE | Returning cached instance of singleton bean 'RedeliveryPolicy'
16:29:43,780 | DEBUG | cc5bd91-thread-1 | DefaultErrorHandler | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | Failed delivery for exchangeId: ID-1NVC-52527-1436958153799-314-4. On delivery attempt: 0 caught: my.custom.error.RedeliveryException
16:29:43,780 | DEBUG | cc5bd91-thread-1 | RedeliveryPolicy | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | Sleeping for: 60 millis until attempting redelivery
16:29:43,840 | DEBUG | cc5bd91-thread-1 | DefaultListableBeanFactory | | 59 - org.springframework.beans - 3.0.5.RELEASE | Returning cached instance of singleton bean 'RedeliveryPolicy'
16:29:43,840 | DEBUG | cc5bd91-thread-1 | DefaultErrorHandler | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | Failed delivery for exchangeId: ID-1NVC-52527-1436958153799-314-4. On delivery attempt: 1 caught: my.custom.error.RedeliveryException
16:29:43,840 | DEBUG | cc5bd91-thread-1 | RedeliveryPolicy | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | Sleeping for: 60 millis until attempting redelivery
16:29:43,900 | DEBUG | cc5bd91-thread-1 | DefaultListableBeanFactory | | 59 - org.springframework.beans - 3.0.5.RELEASE | Returning cached instance of singleton bean 'RedeliveryPolicy'
16:29:43,900 | DEBUG | cc5bd91-thread-1 | DefaultErrorHandler | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | Failed delivery for exchangeId: ID-1NVC-52527-1436958153799-314-4. On delivery attempt: 2 caught: my.custom.error.RedeliveryException
16:29:43,900 | DEBUG | cc5bd91-thread-1 | RedeliveryPolicy | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | Sleeping for: 60 millis until attempting redelivery
16:29:43,960 | DEBUG | cc5bd91-thread-1 | DefaultListableBeanFactory | | 59 - org.springframework.beans - 3.0.5.RELEASE | Returning cached instance of singleton bean 'RedeliveryPolicy'
16:29:43,960 | DEBUG | cc5bd91-thread-1 | DefaultErrorHandler | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | Failed delivery for exchangeId: ID-1NVC-52527-1436958153799-314-4. On delivery attempt: 3 caught: my.custom.error.RedeliveryException
16:29:43,960 | DEBUG | cc5bd91-thread-1 | RedeliveryPolicy | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | Sleeping for: 60 millis until attempting redelivery
16:29:44,020 | DEBUG | cc5bd91-thread-1 | DefaultListableBeanFactory | | 59 - org.springframework.beans - 3.0.5.RELEASE | Returning cached instance of singleton bean 'RedeliveryPolicy'
16:29:44,020 | DEBUG | cc5bd91-thread-1 | DefaultErrorHandler | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | Failed delivery for exchangeId: ID-1NVC-52527-1436958153799-314-4. On delivery attempt: 4 caught: my.custom.error.RedeliveryException
16:29:44,020 | DEBUG | cc5bd91-thread-1 | RedeliveryPolicy | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | Sleeping for: 60 millis until attempting redelivery
16:29:44,080 | DEBUG | cc5bd91-thread-1 | DefaultListableBeanFactory | | 59 - org.springframework.beans - 3.0.5.RELEASE | Returning cached instance of singleton bean 'RedeliveryPolicy'
16:29:44,080 | DEBUG | cc5bd91-thread-1 | DefaultErrorHandler | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | Failed delivery for exchangeId: ID-1NVC-52527-1436958153799-314-4. On delivery attempt: 5 caught: my.custom.error.RedeliveryException
16:29:44,081 | DEBUG | cc5bd91-thread-1 | NMR | | 81 - org.apache.servicemix.nmr.core - 1.4.0.fuse-03-01 | Channel org.apache.servicemix.nmr.core.ChannelImpl@7dc124e5 dispatching exchange: [
谢谢你的解释。我将发布正确答案:
<route id="sampleRoute">
<from uri="direct:anotheRoute" />
<to uri="direct:kaboom" />
<onException>
<exception>java.net.SocketException</exception>
<exception>java.net.ConnectException</exception>
<exception>my.custom.error.RedeliveryException</exception>
<redeliveryPolicy ref="customRedeliveryPolicy" />
</onException>
</route>
<route errorHandlerRef="noErrorHandler">
<from uri="direct:kaboom />
<to uri="nmr:kaboom/>
<choice>
<when>
<xpath>//result = 'true'</xpath>
<to uri="direct:anotherAnotherRoute" />
</when>
<otherwise>
<throwException ref="redeliveryException" />
</otherwise>
</choice>
</route>
豆子里的声明:
<bean id="noErrorHandler" class="org.apache.camel.builder.NoErrorHandlerBuilder"/>
这并不奇怪,Camel的错误处理程序和重新交付是从失败的步骤开始执行的,而不是从路线的开始。
你可以不用再次抛出错误调用direct:anotherRoute
,唯一的问题是如果你这么做太频繁,你的调用堆栈可能会变得太深。
你可以做的是把那个nmr: kaboom
放到一个单独的路由中,并将其配置为具有noErrorHandler
,然后从第一个路由开始,用Direct:
调用它,然后错误处理程序可以从头重新传递整个路由。
我正在使用带有Apache骆驼的Spring Boot。我正在从控制器调用路由。一旦路由完成,控制就会返回控制器。我正在VerifyLimitProcess和批准限制处理器中生成响应。如果我没有在路由中提供窃听配置,控制器会按预期检索标头和正文。但如果我在路由中引入窃听,控制器会将标头和正文接收为null。如果有人指出我需要做什么,以便我可以在选择语句中引入两个处理器的窃听配置,即VerifyLi
我正在遵循位于Camel MyBatis Integration guide的安装指南。我使用的是Service Mix 5.0.1。我使用了安装spring mybatis的功能,它支持3.2.4。释放我的SqlMapConfig文件只包含有关TypeHandler和TypeAlias的信息。 当我开启服务混合,然后启动我的应用程序,我收到以下堆栈跟踪: ...还有50个 我的Bean定义如下:
我有一个Quarkus应用程序,它使用Apache-Camel并在本地运行良好。当我构建它并尝试运行docker容器时,我收到以下错误: 我的分级依赖关系是 } 当我在IntelliJ终端中使用“夸克斯开发”运行它时,我没有问题。我是否尝试运行容器,但会出现错误。为什么会发生这种情况?我不知道如何解决它。 编辑: 处理HttpException的位置: 处理程序本身: }
我试图弄清楚骆驼的节流概念。我已经看到了骆驼的航线政策,但这适用于许多飞行中的交换。 我的路线如下: 现在我的用例是,我想在这些路由之间传输比如说2000条消息,我知道可以通过来完成。但是,我不得不决定如何在下一个2000条消息被路由时控制它。我只想在接收者队列变为空时路由下2000条消息。 例如,消息从队列路由到。假设2K消息已成功路由,现在我想挂起我的路由,这样它就不会传输更多的消息,直到队列
我有一个Spring Boot2.25.1应用程序,它使用Camel 2.25.1与camel-kafka,一切都正常工作…在我的Kafka消费者中,我需要添加该功能以按需暂停消费,因此我升级到camel 3.18.1,以便我可以使用可暂停功能。升级到3.18.1后,我收到错误FileNotes与类文件TimeoutAwareAggregationStategy.class. 当我打开camel-
我最近注意到Camel现在有自己的Kafka组件,所以我决定给它一个旋转。 我决定尝试一个很好的简单文件->kafka主题如下...