英文:
how to use a method variable in a from route
问题
我想在条件判断中使用一个局部变量,但是找不到如何实现?
提前感谢您,
private boolean enableSS; //启用或禁用消息传递
this.enableSS = Boolean.parseBoolean(endpointDescriptor.getEnableSS());
from(fromStr).routeId(routeId)
.log("接收到消息 ${file:name} 用于压缩和加密,来自主机 ${host}")
.unmarshal(pgpVerifyAndDecrypt).split(new ZipSplitter())
.streaming().convertBodyTo(String.class)
.wireTap("file:" + fileArchive)
.choice()
.when() //如果 enableSS 是 true 还是 false?
.to(toStr) // 传统目标
.to("file:" + toStrP); //新目标
我希望能够做类似以下的操作 - 如何实现?
.when(enableSS == true) //如果 enableSS 是 true 还是 false?
.to(...
英文:
I would like to use a local variable in a choice when predicate, but, can't find how this is possible?
thank you in advance,
private boolean enableSS; //enable or disable message delivery
this.enableSS = Boolean.parseBoolean(endpointDescriptor.getEnableSS());
from(fromStr).routeId(routeId)
.log("Message received ${file:name} for Compression and Encryption " + " from host " + host)
.unmarshal(pgpVerifyAndDecrypt).split(new ZipSplitter())
.streaming().convertBodyTo(String.class)
.wireTap("file:" + fileArchive)
.choice()
.when() //if the enableSS is true or false ?
.to(toStr) // Legacy destination
.to("file:" + toStrP); //new destination
I hope to be able to do something like - how can this be done?
.when(enableSS == true) //if the enableSS is true or false ?
.to(...
答案1
得分: 1
你可以使用 PredicateBuilder.constant,就像这样:
.when(PredicateBuilder.constant("true".equals(yourArgument)))
----
.end()
英文:
You can use the PredicateBuilder.constant like
.when(PredicateBuilder.constant("true".equals(yourArgument)))
----
.end()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论