Generate a new spring boot camel project by running a maven archetype (maven settings.xml supplied at the end of this article if you need the repositories):

Check you can build and run the project

Check you get some output:

Create a new user and copy the jar to a runnable location

Create a new systemd configuration file at /etc/systemd/system/simple-camel-logger.service

You should now be able to use systemctl to enable, start, and stop the service:

[user@localhost somedir]$ systemctl enable simple-camel-logger.service
[user@localhost somedir]$ systemctl start simple-camel-logger.service
[user@localhost somedir]$ systemctl status simple-camel-logger.service
● simple-camel-logger.service - simple-camel-logger spring boot application
   Loaded: loaded (/etc/systemd/system/simple-camel-logger.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-05-01 09:29:19 BST; 8s ago
 Main PID: 8968 (java)
    Tasks: 44 (limit: 4915)
   Memory: 556.1M
   CGroup: /system.slice/simple-camel-logger.service
           └─8968 /usr/bin/java -jar /var/springboot/simple-camel-logger-1.0.jar

May 01 09:29:25 somebox java[8968]: 09:29:25.356 [main] INFO  o.a.camel.spring.SpringCamelContext - StreamCaching is not in use. If using streams then its reco>
May 01 09:29:25 somebox java[8968]: 09:29:25.382 [main] INFO  o.a.camel.spring.SpringCamelContext - Route: route1 started and consuming from: timer://foo?perio>
May 01 09:29:25 somebox java[8968]: 09:29:25.383 [main] INFO  o.a.camel.spring.SpringCamelContext - Total 1 routes, of which 1 are started
May 01 09:29:25 somebox java[8968]: 09:29:25.384 [main] INFO  o.a.camel.spring.SpringCamelContext - Apache Camel 2.21.0.fuse-720050-redhat-00001 (CamelContext:>
May 01 09:29:25 somebox java[8968]: 09:29:25.448 [main] INFO  o.s.b.c.e.u.UndertowEmbeddedServletContainer - Undertow started on port(s) 8081 (http)
May 01 09:29:25 somebox java[8968]: 09:29:25.454 [main] INFO  o.s.c.s.DefaultLifecycleProcessor - Starting beans in phase 0
May 01 09:29:25 somebox java[8968]: 09:29:25.464 [main] INFO  o.s.b.a.e.jmx.EndpointMBeanExporter - Located managed bean 'healthEndpoint': registering with JMX>
May 01 09:29:25 somebox java[8968]: 09:29:25.512 [main] INFO  o.s.b.c.e.u.UndertowEmbeddedServletContainer - Undertow started on port(s) 8080 (http)
May 01 09:29:25 somebox java[8968]: 09:29:25.515 [main] INFO  com.codergists.Application - Started Application in 5.419 seconds (JVM running for 5.913)
May 01 09:29:26 somebox java[8968]: 09:29:26.393 [Camel (MyCamel) thread #1 - timer://foo] INFO  route1 - >>> Hello World

[user@localhost somedir]$ systemctl stop simple-camel-logger.service

Maven Repositories

Add the following to your ~/.m2/settings.xml file so maven knows how to resolve the fuse and redhat java artefacts.

References


codergists