我想在收到订阅后立即确认 Google Pubsub 消息。但是,在到达 Camel 路由的末尾之前,Camel 不会这样做,这意味着如果在从订阅中获取消息的下游某处抛出异常,Google Pubsub 会重新传递消息。这变成了一个无限循环。
这是我的路线:
rest("myURL")
.post("rest_of_url")
.outType(String.class)
.route()
.routeId("invite-candidates-route")
.setExchangePattern(ExchangePattern.InOnly)
.process(processor1) // business logic plus create message and save
// in exchange properties
.wireTap("direct:toProcessor2");
from("direct:toProcessor2")
.setExchangePattern(ExchangePattern.InOnly)
.process(processor2) // get message from exchange and convert to
// binary for Google pubsub
.to("google-pubsub://MyProjectId:myTopic"));
from("google-pubsub://MyProjectId:mySubscription")
.description("Pull the message from the email pubsub.")
.process(processor3) // Get message from pubsub and convert to
// Object. Put in exchange body
.to("direct:toProcessor4")
;
from("direct:toProcessor4")
.process(processor4) // More business logic.
因此,如果处理器 4 抛出异常,则消息永远不会被确认,并且我们有一个循环。
有人知道如何解决这个问题吗?