Available as of Camel 2.14
Spark Java requires Java 8 runtime.
Maven users will need to add the following dependency to their pom.xml for this component:
Path using Spark syntax
The path option is defined using a Spark REST syntax where you define the REST context path using support for parameters and splat. See more details at the Spark Java Route documentation.
The following is a Camel route using a fixed path
And the following route uses a parameter which is mapped to a Camel header with the key "me".
Mapping to Camel Message
The Spark Request object is mapped to a Camel Message as a
For example the given route below uses Spark splat (the asterisk sign) in the context path which we can access as a header form the Simple language to construct a response message.
Apache Camel provides a new Rest DSL that allow to define the REST services in a nice REST style. For example we can define a REST hello service as shown below:
See more details at the Rest DSL.
There is a camel-example-spark-rest-tomcat example in the Apache Camel distribution, that demonstrates how to use camel-spark-rest in a web application that can be deployed on Apache Tomcat, or similar web containers.