GLMills
GLMills

Reputation: 638

how to use a method variable in a from route

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

Upvotes: 0

Views: 735

Answers (1)

PraveenKumar K G
PraveenKumar K G

Reputation: 186

You can use the PredicateBuilder.constant like

 .when(PredicateBuilder.constant("true".equals(yourArgument)))
            ----
  .end()

Upvotes: 1

Related Questions