java - 如何在 from 路由中使用方法变量
问题描述
我想在谓词的选择中使用局部变量,但是,找不到这怎么可能?
先感谢您,
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
我希望能够做类似的事情 - 这怎么做?
.when(enableSS == true) //if the enableSS is true or false ?
.to(...
解决方案
您可以使用 PredicateBuilder.constant 之类的
.when(PredicateBuilder.constant("true".equals(yourArgument)))
----
.end()
推荐阅读
- javascript - Webpack 5 Html Webpack Plugin 错误“错误:子编译失败:”
- python - 如何在 for 循环中使用 Django 模板过滤器?
- sql-server - 将 Pandas 数据框插入 SQL Server 执行和执行的时间过长
- unit-testing - UWP 单元测试不会出现在 Rider 中
- javascript - 将加载的模型分配给对象三个 Js 中的值
- javascript - 我无法访问我的 axios 发布请求中的数据
- setuptools - 相当于诗歌中的`python setup.py develop`
- c++ - 使用字符串分隔符 (,) 在 C++ 中拆分字符串的结尾
- rust - 如何在 rust 1.26 及更高版本上将多个字符串写入文件而不会相互覆盖?
- android - Android:尝试通过 SmsManager 发送短信会将消息重定向到没有地址的默认应用程序