如何在 from 路由中使用方法变量

how to use a method variable in a from route

我想在 choice when 谓词中使用局部变量,但是找不到这怎么可能?

提前谢谢你,

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()