In camel routes, null check of body content can be done as given below:
.choice() .when(body().isNull()) .log(LoggingLevel.INFO, "Body is null") .otherwise() .log(LoggingLevel.INFO, "Body is not null") .endChoice()
If you are doing null check on a exchange header, this can be done using:
.choice() .when(header("sampleheader").isNull()) .log(LoggingLevel.INFO, "Value of exchange header 'sampleheader' is null") .otherwise() .log(LoggingLevel.INFO, "Value of exchange header 'sampleheader' is not null") .endChoice()
Similarly you can do null check on exchange property using:
.choice() .when(exchangeProperty("sampleproperty").isNull()) .log(LoggingLevel.INFO, "Value of exchange property 'sampleproperty' is null") .otherwise() .log(LoggingLevel.INFO, "Value of exchange property 'sampleproperty' is not null") .endChoice()
We can use .isNotNull()
to negate the above .isNull()
check.