Apache camel camel 3.4中不推荐Exchange.NOTIFY\事件交换选项,正在寻找替代选项

Apache camel camel 3.4中不推荐Exchange.NOTIFY\事件交换选项,正在寻找替代选项,apache-camel,spring-camel,apache-camel-3,Apache Camel,Spring Camel,Apache Camel 3,我一直在事件通知程序下的Exchange创建事件中使用生产者模板中的Exchange.NOTIFY_事件选项,以避免再次调用Exchange创建事件,在我使用camel 2.24 core时,它工作正常,但现在由于我升级到camel 3.4.0,它不再工作。看起来Exchange.NOTIFY\u事件选项已弃用 String response = (String) producerTemplate.sendBodyAndProperty("event",

我一直在事件通知程序下的Exchange创建事件中使用生产者模板中的Exchange.NOTIFY_事件选项,以避免再次调用Exchange创建事件,在我使用camel 2.24 core时,它工作正常,但现在由于我升级到camel 3.4.0,它不再工作。看起来Exchange.NOTIFY\u事件选项已弃用

String response = (String) producerTemplate.sendBodyAndProperty("event",
                        ExchangePattern.InOut, inputPayload, Exchange.NOTIFY_EVENT, Boolean.TRUE);
有人能告诉我骆驼3.4中的替代方案是什么,它相当于Exchange.NOTIFY\u事件吗?如果有人能就此提供一些见解,我们将不胜感激

更新日期:2020年10月28日:

我发现Exchange.NOTIFY_事件已被弃用,并将其移动到名为ExtendedExchange的新Exchange。现在,此交换可以适应ExtendedExchange,并可以如下设置notifyEvent方法

exchange.adapt(ExtendedExchange.class).setNotifyEvent(true);
但问题尚未解决。这是当前的代码

CamelContext context = exchange.getContext();
ProducerTemplate producerTemplate = context.createProducerTemplate();
Object obj = producerTemplate.sendBodyAndProperty("event",
                        ExchangePattern.InOut, inputPayload, Exchange.NOTIFY_EVENT, Boolean.TRUE);
我已经在使用EventNotifierSupport创建的exchangeCreated通知中,我想调用另一个不应再次创建通知的路由。这就是为什么我以前通过设置exchange.NOTIFY\u事件属性来调用这种方法。因为sendBodyAndProperty方法创建了新的exchange并将属性设置为notify

但现在文档中说,我们需要将exchange调整为extendedExchange,并在其中将notifyEvent设置为true。我这里的问题是,既然使用sendBodyAndProperty方法时exchange是在内部创建的,那么我们如何适应extendedExchange呢


我们怎么做?有人能帮我解决这个问题吗?我们有其他的方法来解决这个问题吗?

最后我找到了一个解决这个问题的方法,但不确定我们是否有其他简单的方法来解决这个问题。不过,我暂时同意这一点

我们只需要将此标志设置为NotNotify,但此方法位于extendedContext中,它是作为camel 3及更高版本的一部分新引入的。我使用的是骆驼3.4

camelcontextended.setEventNotificationApplicable(false)

下面是完整的代码

CamelContext context = exchange.getContext();

ModelCamelContext camelContext = context.adapt(ModelCamelContext.class);
ExtendedCamelContext camelContextExtended =context.adapt(ExtendedCamelContext.class);

camelContextExtended.setEventNotificationApplicable(false);

ProducerTemplate producerTemplate = context.createProducerTemplate();
Object obj = producerTemplate.sendBodyAndProperty("event",
                        ExchangePattern.InOut, inputPayload, Exchange.NOTIFY_EVENT, Boolean.TRUE);

camelContextExtended.setEventNotificationApplicable(true);

希望这对将来的人有所帮助。

最后我找到了一个解决这个问题的方法,但不确定我们是否有其他简单的方法来解决它。不过,我暂时同意这一点

我们只需要将此标志设置为NotNotify,但此方法位于extendedContext中,它是作为camel 3及更高版本的一部分新引入的。我使用的是骆驼3.4

camelcontextended.setEventNotificationApplicable(false)

下面是完整的代码

CamelContext context = exchange.getContext();

ModelCamelContext camelContext = context.adapt(ModelCamelContext.class);
ExtendedCamelContext camelContextExtended =context.adapt(ExtendedCamelContext.class);

camelContextExtended.setEventNotificationApplicable(false);

ProducerTemplate producerTemplate = context.createProducerTemplate();
Object obj = producerTemplate.sendBodyAndProperty("event",
                        ExchangePattern.InOut, inputPayload, Exchange.NOTIFY_EVENT, Boolean.TRUE);

camelContextExtended.setEventNotificationApplicable(true);
希望这能对将来的人有所帮助