如何将参数从骆驼路线传递到命名的名称?
我在Spring-Boot上有一个运行骆驼的应用程序。 我想从骆驼路线中将被重试的参数重试。
名字Query:
@NamedQuery(name = "findFailedMessages", query = RawMessageTx.HQL_FIND_FAILED_MESSAGES)
public class RawMessageTx extends BaseEntityWithTransmitStatus implements Serializable {
public static final String HQL_FIND_FAILED_MESSAGES = "SELECT x from RawMessageTx x WHERE x.status = 'FAILED' and x.tryAgain = 1 and x.retriesAttempted <= :retriesAllowed ORDER BY x.created ";
路线:
from("seda:retry_poll_failed_messages").routeId("retry_poll_failed_messages")
.setHeader("retriesAllowed", constant(retriesAllowed))
.toF("jpa:%s?namedQuery=findFailedMessages&maximumResults=%d", RawMessageTx.class.getName(),
maxMessagesPerPollAttempt)
.split(body())
.to("direct:anotherEndpoint");
我尝试了不同的事情,它无法正常工作,在此上找不到一个很好的示例。
I have an application running camel on spring-boot.
I want to pass a parameter retriesAllowed to a namedQuery from a camel route.
namedQuery:
@NamedQuery(name = "findFailedMessages", query = RawMessageTx.HQL_FIND_FAILED_MESSAGES)
public class RawMessageTx extends BaseEntityWithTransmitStatus implements Serializable {
public static final String HQL_FIND_FAILED_MESSAGES = "SELECT x from RawMessageTx x WHERE x.status = 'FAILED' and x.tryAgain = 1 and x.retriesAttempted <= :retriesAllowed ORDER BY x.created ";
Route:
from("seda:retry_poll_failed_messages").routeId("retry_poll_failed_messages")
.setHeader("retriesAllowed", constant(retriesAllowed))
.toF("jpa:%s?namedQuery=findFailedMessages&maximumResults=%d", RawMessageTx.class.getName(),
maxMessagesPerPollAttempt)
.split(body())
.to("direct:anotherEndpoint");
I tried different things and it does not work and I can't find a good example online on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这在JPA组件的文档中进行了解释:
这意味着您必须做类似的事情:
where“ mymap ”是'可提供骆驼注册表。
(除其他)注册这种豆的一种可能是骆驼
处理器
(当然要在JPA端点之前调用)This is explained in the doc of JPA component:
This means that you have to do something like:
Where "myMap" is the name of a bean of type 'java.util.Map' that is available in Camel registry.
One possible way (among others) to register such bean could be a Camel
Processor
(to invoke before the jpa endpoint of course)