Grape Component
Available as of Camel 2.16
Grape component allows you to fetch, load and manage additional jars when CamelContext
is running. In practice with Camel Grape component you can add new components, data formats and beans to your CamelContext
without the restart of the router. Grape component supports only producer endpoints.
URI format
grape:defaultMavenCoordinates[?options]
For example the following snippet loads Camel FTP component:
from("direct:loadCamelFTP"). to("grape:org.apache.camel/camel-ftp/2.15.2");
You can also specify the Maven coordinates by sending them to the endpoint as the exchange body:
from("direct:loadCamelFTP"). setBody().constant("org.apache.camel/camel-ftp/2.15.2"). to("grape:defaultMavenCoordinates");
Adding the Grape component to the project
Maven users will need to add the following dependency to their pom.xml
for this component:
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-grape</artifactId> <version>x.y.z</version> <!-- use the same version as your Camel core version --> </dependency>
Default payload type
By default Camel Grape component operates on the String payloads:
producerTemplate.sendBody("grape:defaultMavenCoordinates", "org.apache.camel/camel-ftp/2.15.2");
But of course Camel build-in type conversion API can perform the automatic data type transformations for you. In the example below Camel automatically converts binary payload into String:
producerTemplate.sendBody("grape:defaultMavenCoordinates", "org.apache.camel/camel-ftp/2.15.2".getBytes());
Headers
The following headers are recognized by the Grape component:
Header | Java constant | Endpoint type | Value type | Description |
---|---|---|---|---|
CamelGrapeCommand | GrapeConstants.GRAPE_COMMAND | Producer | org.apache.camel.component.grape.GrapeCommand | The command to be performed by the Grape endpoint. Default to grab . |