Serve winners by familiarising yourself with the prototyping tool that helps you run, iterate and test your Camel applications.
This chapter is an introductory taste of Camel JBang showing you a basic group of commands. Hopefully you’ll get to see how much you can sharpen your axe when making a good use of Camel JBang.
|
Note
|
Familiarity with Apache Camel is helpful but not required to complete this lab. If you have little or no prior experience, consider reviewing an introduction to Enterprise Integration Patterns and Apache Camel first: |
This chapter is recommended to understand how Camel JBang helps you work fast with Apache Camel
Camel JBang is a command-line interface (CLI) that accelerates prototyping by letting developers quickly create, validate, and tweak flows without complex setups, making it perfect for rapid experimentation.
Whether you’re working in your local machine or from Dev Spaces, you’ll need to open a terminal. If you’re working locally we recommend using VS Code as the examples below are based on this editor, but you can use any other terminal you prefer.
Open a terminal following the steps illustrated below (Dev Spaces example):
The picture below shows the terminal in VS Code.
Copy and paste the following into your terminal:
mkdir lab
cd labWhen created the first time, your lab directory is empty:
📁 workshop 📁 lab (empty)
They say playing is a great way to learn, so let’s play for a bit. While you’re at it you’ll discover a few tricks Camel JBang has in the bag.
Pretend we’re about to organise a tennis tournament. Let us introduce to you player1:
Copy and paste the following into your terminal to create the player1.yaml file.
|
Note
|
You’ll be asked to confirm the paste action, tick "✓ Do not ask me again" and click Paste. |
cat <<EOF > player1.yaml
- route:
id: player1
from:
uri: file:court/side1
parameters:
delete: true
steps:
- log:
message: (ping)⋅⋅⋅━━━► 🥎
- delay:
constant: "{{pace:3000}}"
- to:
uri: file:court/side2
EOF|
Note
|
player1 one plays on one side of the court and hits every ball that comes his way. When hitting the ball, it crosses the court (at a given pace) to the other side.
|
Run this command to get player1 on the court, ready to play:
camel run player1.yaml|
Note
|
Observe the simplicity of it all, no more than one player in the game, no dependency descriptors, no additional files needed to run the show. Camel JBang figures all out, it reads player1 and provides all that is needed to the run the game.
|
In your terminal you’ll see player1 ready:
2025-10-26 12:40:32.210 INFO 2243 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 4.15.0 (player1) started in 242ms ...
Also, watching closely your folder structure, you’ll see on which side player1 stands waiting for balls:
❯ lab ❯ court/side1
player1 is ready. Give him a 🥎.
From the terminal’s top right corner, click + to open a second terminal, as shown below:
From the new terminal, use Camel JBang to hand a ball to player1:
|
Tip
|
The send command is very helpful to test the game, you can throw balls to players and see what happens.
|
camel cmd send player1 --header CamelFileName=🥎Get back to the first terminal where player1 is running:
Inspect the terminal’s output, you should see player1 hitting the ball to the other side of the court:
2025-10-26 12:50:12.951 INFO 2243 --- [e://court/side1] player1.yaml:8 : (ping)⋅⋅⋅━━━► 🥎
Have a look to the court. You should see the ball resting on the other side:
|
Note
|
The downside of playing tennis with a single player is that balls end up motionless on the other side of the court. |
Before we continue, give player1 some rest. Stop the action with Ctrl+C.
We introduce to you the ball boy, he will ensure the court is always tidy.
Copy and paste the following into your terminal to create the the-ballboy.yaml file:
cat <<EOF > the-ballboy.yaml
- route:
id: ballboy
from:
uri: timer:check-court
steps:
- filter:
groovy:
expression: >-
def court = ['court/side1/🥎', 'court/side2/🥎'];
def file = court.find { new File(it).exists() }?.with { new File(it) };
if (file?.exists() && (System.currentTimeMillis() - file.lastModified()) > {{wait:6000}} )
return file.delete();
else
return false;
steps:
- log:
message: "🥎 cleared, court ready."
EOF|
Note
|
In Camel, certain tasks require agility. Notice the ballboy making use of Groovy to look at both sides of the court, and retrieve any ball sitting on the court for too long (6 seconds). |
When you see everyone ready, use the command below to restart:
camel run *|
Note
|
Camel JBang makes things easy:
|
Inspect the terminal logs, you should see the ball boy already at work:
2025-10-26 18:23:53.558 INFO 20299 --- [r://check-court] the-ballboy.yaml:17 : 🥎 cleared, court ready.
Look also at the court. You’ll notice the ball has been cleared:
Let player1 practice a bit more. When done, press Ctrl+C to give him some rest.
Ok, practice is over, let’s organise a real game.
For a proper game to take place, you need more than just one player. We introduce to you player2:
Copy and paste the following into your terminal to create the player2.yaml file:
cat <<EOF > player2.yaml
- route:
id: player2
from:
uri: file:court/side2
parameters:
delete: true
steps:
- log:
message: " 🥎 ◄━━━⋅⋅⋅(pong)"
- delay:
constant: "{{pace:3000}}"
- to:
uri: file:court/side1
EOF|
Note
|
These players really train for doing just one thing. |
Because this is a prestigious tournament, there’s a protocol to follow:
-
Let spectators sit comfortably while players and staff wait in the locker rooms. Press Ctrl+C (if you didn’t already) to follow on with preparations.
-
Let the ball boy go on court first to get ready:
camel run the-ballboy.yaml --background
NoteThe flag --backgroundindicates Camel JBang to run the process detached. -
Present the players to the public and let them jump on court:
camel run player1.yaml --background --dev
camel run player2.yaml --background --dev
NoteThe flag --devindicates Camel JBang to do live code reloads (new racket for example). -
Before the game starts, check everyone is ready:
camel ps
NoteThe pscommand is handy to check who’s playing and who’s not, who’s ready and who’s not, and who’s busy and who’s not. -
Join the crowd and enjoy watching the game:
camel log
NoteThe logcommand aggregates all the action on court so that you’re aware of all that’s happening. You can also focus on one single player, or even the ball boy if curious of what the job entails. For example to focus on player 1, you would runcamel log player1.
Ok, the ball boy is ready, the players are ready, and the public is anxious waiting to see the game start.
player1 starts serving, hand him a 🥎
camel cmd send player1 --header CamelFileName=🥎Inspect your terminal output, you should see both players hitting the ball hard:
player1 | 2025-10-26 19:01:36.006 INFO 22363 --- [e://court/side1] player1.yaml:8 : (ping)⋅⋅⋅━━━► 🥎 player2 | 2025-10-26 19:01:39.106 INFO 22578 --- [e://court/side2] player2.yaml:8 : 🥎 ◄━━━⋅⋅⋅(pong) player1 | 2025-10-26 19:01:42.509 INFO 22363 --- [e://court/side1] player1.yaml:8 : (ping)⋅⋅⋅━━━► 🥎 player2 | 2025-10-26 19:01:45.610 INFO 22578 --- [e://court/side2] player2.yaml:8 : 🥎 ◄━━━⋅⋅⋅(pong) ...
It’s a long rally !
Also, see the ball on the court going back and forth:
But player1 feels the laces of his shoe are loose and has to stop to tie them up. Run the command:
camel cmd stop-route --id player1Because player1 stopped hitting the ball, spectators will see player2 hitting one last time, player1 tying up his shoe laces, and the ball boy retrieving the ball:
player2 | ... : 🥎 ◄━━━⋅⋅⋅(pong) player1 | ... : Stopped player1 (file://court/side1) the-ballboy| ... : 🥎 cleared, court ready.
It’s a good moment to look at the game statistics. Get the stats with:
camel get routeStats will reveal who’s hitting faster (and other measurements as well):
|
Note
|
Observe player1 has stopped playing for a moment, but is still very much part of the game.
|
PID NAME ID FROM REMOTE STATUS AGE COVER MSG/S TOTAL FAIL INFLIGHT MEAN MIN MAX LAST DELTA SINCE-LAST 22140 the-ballboy ballboy timer://check-court Started 6m3s 2/2 1.00 363 0 0 2 0 841 0 0 0s/0s/- 22363 player1 player1 file://court/side1?delete=true x Stopped 3/3 0.00 25 2 0 2001 2001 2007 2001 0 1m31s/1m29s/1m41s 22578 player2 player2 file://court/side2?delete=true x Started 5m21s 3/3 0.00 23 0 0 2001 2001 2012 2001 0 1m29s/1m27s/-
It seems player1 sorted out the shoe laces problem and is ready to play again. Get the player in position again with:
camel cmd start-route --id player1It’s player2 's turn to serve, hand him a 🥎
camel cmd send player2 --header CamelFileName=🥎Here they go again, another insane rally.
It seems the wind is peaking up, some clouds have covered the sky and some spots of rain are dotting the court. Weather conditions can really change the game in tennis.
The rain drops make the ball wetter and heavier, the hitting starts to sound funny and the exchanges feel slower. While the intense rally keeps going (ping/pong), make these changes on the players:
-
In
player1.yaml, change the log message top1ng, and the pace of the ball to{{pace:4000}}(slower) -
In
player2.yaml, change the log message top0ng, and the pace of the ball to{{pace:4000}}(slower)
|
Note
|
Camel JBang reacts to live code changes and ensures the new game behaviour takes immediate effect. |
You should see in the terminal Camel reacting with reloads:
player1 | ... RouteWatcherReloadStrategy : Routes reloaded summary (total:1 started:1) player1 | ... RouteWatcherReloadStrategy : Started player1 (file://court/side1) (source: player1.yaml:4)
Now you’ll notice more clearly, the funny sound from the rackets, and the game slowing down:
player2 | ... : 🥎 ◄━━━⋅⋅⋅(p0ng) player1 | ... : (p1ng)⋅⋅⋅━━━► 🥎 ...
That’s unfortunate… player1 slips on the wet court. Were his shoe laces tied well? We hope he is not hurt. After a close look, it is clear: he is injured and must leave the game.
camel stop player1|
Tip
|
Run camel ps and you’ll notice player1 no longer takes part in the game.
|
At this point, it makes no sense to continue the event, the announcement is made, and the game is halted:
camel stop|
Note
|
When no name is specified, Camel JBang stops all. |
We’re sorry it ended this way, but don’t let it spoil your day, there are many other matches to watch!
🥎🥎🥎 Keep exploring tutorials to see more. 🥎🥎🥎
Make sure your lab folder stays clean in preparation for your next lab exercises.
Run the command below:
rm -r *Your lab folder should contain no files or directories.
Is your lab folder empty? Get ready to start working!
This was only a brief introduction on how to work fast with a few Camel files. Camel JBang has many more commands to assist you in your development.
It’s worth to quickly recap the collection of commands you just used:
-
For running Camel, how to:
-
Run single file
-
Run all
-
Run in the background
-
Run in dev mode (hot reload)
-
-
For troubleshooting/monitoring, how to:
-
List running instances
-
Follow logs
-
Start/Stop routes in process
-
Get route details
-
Send message to endpoint
-
-
For stopping Camel, how to:
-
Stop single instance
-
Stop all
-
Continue exploring other examples to discover, not only what Camel JBang can do for you beyond what you’ve just seen, but also other companion tools empowering the developer to work fast with Apache Camel.










