Home > coding, java > Trigger Camel route from command line

Trigger Camel route from command line

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: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: