Skip to content
𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ

Share the knowledge

𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ

Share the knowledge

Check the size of a List/Map from Apache camel route

Posted on March 6, 2017September 20, 2021 By sastrija

We can check the size of a java.util.ListΒ using below code.

.choice()
  .when(simple("${body.size() > 10}"))
    .log(LoggingLevel.INFO, "List size is greater than 10")
  .when(simple("${body.size() > 0}"))
    .log(LoggingLevel.INFO, "List size is greater than 0")
  .otherwise()
    .log(LoggingLevel.INFO, "List is empty")
.endChoice()

Same logic can be used for other collection objects in Java.

Please not that you have to add null check before this if you expect null values. Applying null check in camel routes is explained here:Β http://k2i.987.mywebsitetransfer.com/2016/01/05/null-check-in-camel-routes/

Related

Uncategorized

Post navigation

Previous post
Next post
©2026 𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ | WordPress Theme by SuperbThemes