MuleESB / Apache Camel Interview Questions
How do you use the Camel Expression Language (Simple, SpEL, JSONPath, XPath)?
Camel uses expressions and predicates everywhere a dynamic value is needed: filter(), when(), setHeader(), log(), split(), and idempotentConsumer(). Four languages are commonly used:
- Simple: Camel built-in. Resolves body, headers, properties, bean calls, date formatting, arithmetic. Zero extra dependency.
- SpEL (Spring Expression Language): Spring-only. Access Spring beans and methods.
- JSONPath: Evaluates a JSONPath expression against the JSON body.
- XPath: Evaluates an XPath expression against the XML body.
// Simple: filter by header, extract body field
from("direct:in")
.filter(simple("${header.priority} == HIGH"))
.to("direct:highPriority");
// XPath: extract attribute to header
from("direct:xml")
.setHeader("orderId", xpath("//order/@id", String.class))
.log("Order: ${header.orderId}");
// JSONPath: split JSON array
from("direct:jsonIn")
.split().jsonpath("$.orders[*]")
.to("direct:processItem");
// SpEL: call Spring bean
from("direct:validate")
.filter(spel("#{@orderService.isValid(body)}"))
.to("direct:valid");Simple is the right first choice for most routing predicates — it has zero overhead and no extra dependency. Use XPath when input is XML and you need node selection. Use JSONPath for JSON body queries. Use SpEL when you need to call Spring-managed beans inside predicates. Pre-compile Simple expressions at build time using the camel-maven-plugin to catch typos early.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
