Hope this doesn't sound ridiculous, but how can I discard a message in Camel on purpose?
Until now, I sent them to the Log-Component, but meanwhile I don't even want to log the withdrawal.
Is there a /dev/null Endpoint in Camel?
Hope this doesn't sound ridiculous, but how can I discard a message in Camel on purpose?
Until now, I sent them to the Log-Component, but meanwhile I don't even want to log the withdrawal.
Is there a /dev/null Endpoint in Camel?
您可以使用邮件过滤器 eip 过滤掉不需要的邮件。 http://camel.apache.org/message-filter
没有 dev/null 组件。
还有一个 <stop /> 可以在路由中使用,当有消息命中时,它将停止继续路由。
我们在 dev/null 上最接近的是路由到日志,您将 logLeve=OFF 设置为选项。
感谢我的同事(代号:cayha)...
您可以将Stub 组件用作等效于/dev/null
.
例如
activemq:route?abc=xyz
变成
stub:activemq:route?abc=xyz
虽然我不知道这个组件的内部工作原理(以及是否存在内存泄漏等危险),但它对我有用,而且我看不出这样做有什么缺点。
<camelContext ...>
<propertyPlaceholder id="properties" location="ref:myProperties"/>
</camelContext>
// properties
cool.end=mock:result
# cool.end=result
// route
from("direct:start").to("properties:{{cool.end}}");
我参加聚会有点晚了,但是您可以在交易所设置一个标志,如果它不符合您的条件,则使用该标志仅跳过该消息(通过调用停止)。
@Override
public void configure() throws Exception {
from()
.process(new Processor() {
@SuppressWarnings("unchecked")
@Override
public void process(Exchange exchange) throws Exception {
exchange.setProperty("skip", false);
byte[] messageBytes = exchange.getIn().getBody(byte[].class);
if (<shouldNotSkip>) {
} else { //skip
exchange.setProperty("skip", true);
}
}
}).choice()
.when(exchangeProperty("skip").isEqualTo(true))
.stop()
.otherwise()
.to();
}