Archive

Posts Tagged ‘camel’

Trigger Camel route from command line

July 17, 2017 Leave a comment

Let’s say we have an Apache Camel route with an entry point like this:

from("direct:start")
    // other route steps 

How to trigger “direct:start” from the command line?

Use JMX

The JMX instrumentation agent is enabled in Camel by default.
In Camel 2.9+ no special jars are required for JMX.
For details, see the Camel JMX documentation.

  • Determine the process id of your Camel Java process.
  • Determine which user id your Camel process is running as.
  • Download or build the jmxterm tool. You need the “uber” jar.

On the same computer and as the same user, execute jmxterm like this:

java -jar jmxterm-*-uber.jar -l ${pid} -i jmxterm-script.txt

With a file jmxterm-script.txt like this:

bean org.apache.camel:context=camel-1,name="camel-1",type=context
run sendStringBody "direct:start" ""

This calls sendStringBody(..) on the ManagedCamelContext and triggers the route for you.

Advertisements
Categories: coding, java Tags: , ,