camel-plantuml is a tool which helps to generate PlantUML activity diagrams which describe Apache Camel routes, based on an actual running Camel context.
It allows to have diagrams where you can see interactions between endpoints and routes.
If you consider following routes:
from(timer("foo").period(5000)).id("slowTimerRoute")
.description("Route which generates slow periodic events")
.setBody(constant("slow"))
.to(seda("endpoint1"));
from(timer("bar").period(1000)).id("fastTimerRoute")
.description("Route which generates fast periodic events")
.setBody(constant("fast"))
.to(seda("endpoint1"));
from(seda("endpoint1")).id("mainRoute")
.description("Route which handles processing of the message")
.log(LoggingLevel.INFO, "${body}")
.enrich().constant("direct://endpoint2")
.toD(mock("mock-${body}"));
from(direct("endpoint2")).id("transformRoute")
.description("Route which transforms the message")
.transform(simple("${body}${body}"));
It will allow you to generate these images:
This tool is intended to be a software documentation tool, it is not intended to be a monitoring tool with real-time metrics or statistics.
This tool needs to have access to a running Camel context instance. It uses the Camel JMX MBeans (which are enabled by default in Camel), and particularly the ones related to routes and processors. Therefore, this tool does NOT work during design time or coding of the Camel routes. It requires an actual running Camel context.
Following processors are handled:
to
)toD
)enrich
)pollEnrich
)wireTap
)recipientList
)It parses the processors to extract URI(s) information. If an expression is found, then, based on the language of the expression:
constant
, it will consider it as a static endpoint (which could be used in other processors or routes).simple
, it will consider it as a dynamic endpoint (with no possible link with other processors or routes).The PlantUML code is exposed through a configurable HTTP endpoint, so it can be re-worked, and finally rendered as an image.
This tool generates PlantUML diagrams with following features:
from
or pollEnrich
) which connects an endpoint to a route.to
,toD
,enrich
,wireTap
or recipientList
) which connects a route to an endpoint.direct
or seda
endpoint.This tool can be used in two different ways:
In this mode, the tool is embedded within your project and connects directly to the MBean server of your application's JVM. The tool exposes the UML diagram directly from your application through a dedicated HTTP endpoint.
The jar is a OSGi bundle, hence it can be used with Apache ServiceMix/Apache Karaf.
<dependency>
<groupId>io.github.ncasaux</groupId>
<artifactId>camel-plantuml-jar</artifactId>
<version>x.y.z</version>
</dependency>
Based on the Apache Camel version you use, choose the correct version:
Apache Camel version | camel-plantuml version |
---|---|
<= 3.15 | 1.3.x |
>= 3.16 and <= 3.19 | 1.4.x |
>= 3.20 | 1.5.x |
>= 4.0 | 1.6.x |
>= 4.4 | >=1.7.x |
getContext().addRoutes(new CamelPlantUmlRouteBuilder());
Default host is localhost
, default port is 8090
, but you can overide them:
getContext().addRoutes(new CamelPlantUmlRouteBuilder("localhost", 8090));
To have all the endpoints, go to:
http://localhost:8090/camel-plantuml/diagram.puml
To connect routes directly (and hide "internal" endpoints), add the following parameter:
http://localhost:8090/camel-plantuml/diagram.puml?connectRoutes=true
To hide endpoints and/or routes which match a URI pattern (.*foo.*
in following example), add the following parameter:
http://localhost:8090/camel-plantuml/diagram.puml?uriFilterPattern=.*foo.*
In this mode, the tool connects remotely to the MBean server of your application's JVM. The tool exposes the UML diagram directly from its dedicated HTTP endpoint. The tool is packaged as a zip file.
Download the latest release from here
Unzip it in the folder of your choice and go into this folder.
Start your application with following parameters and port of your choice:
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port={{JMX_PORT}}
-Djava.rmi.server.hostname={{YOUR_APPLICATION_IP}}
Start locally the tool with parameter jmxHost
:
java -DjmxHost={{YOUR_APPLICATION_IP}}:{{JMX_PORT}} -jar camel-plantuml-zip-x.y.z.jar
To display all the endpoints, go to:
http://localhost:8090/camel-plantuml/diagram.puml
To connect routes directly (and hide "internal" endpoints), add the following parameter:
http://localhost:8090/camel-plantuml/diagram.puml?connectRoutes=true
To hide endpoints and/or routes which match a URI pattern (.*foo.*
in following example), add the following parameter:
http://localhost:8090/camel-plantuml/diagram.puml?uriFilterPattern=.*foo.*
There are multiple options:
The Camel plugin for hawtio has also a graphical representation of routes and route steps. However, there is no graphical connection between routes directly, as each route is drawn individually. So you can not know the routes/endpoints interconnections. That is the main purpose of this tool.
This tool is based on legacy PlantUML activity diagrams. To draw such diagrams, Graphviz is required, and unfortunately, there is no Java implementation of Graphviz...
As far as I know, the new activity diagram is not intended to create connections between any two actions, and that's completely incompatible with diagrams this tool aims to create.
Any suggestion, remark, or question? Feel free to create an issue and/or to contribute by forking and making pull requests!
direct
or seda
to connect routes when using parameter connectRoutes=true
connectRoutes=true