Hi, gang. I hope you’re all doing well.  Two questions if I could.

TL;DR: (so you can decide now if you want to hit <delete> since this is long...)

 1. How to add a resource file from a Maven parent to a child’s fat (Spring 
Boot) JAR?
 2. How to parse command line args and have the main() call 
SpringApplication.run() so that it starts one route or another based on the 
args?

.....

1. The first question is actually more Maven + Spring Boot related than Camel, 
per se, but I know someone here knows the answer.

My Maven project contains a bunch of sub-modules, each of which is a standalone 
Spring Boot + Camel app.

Each module’s POM is fairly bare bones since it inherits almost everything from 
the parent POM, including a generic spring-boot-maven-plugin:repackage for 
packaging everything into a fat JAR.

Each sub-module has its own application.properties *and* pulls in a 
project.properties from the parent.

So, each module's camel-context.xml has a <propertyPlaceholder> that looks 
something like:

  [...]
  <propertiesLocation resolver="file"      path="resources/project.properties" 
optional="false">
  <propertiesLocation resolver="classpath" path="application.properties"       
optional="false">
  [...]

This works perfectly in IntelliJ.  The module really is seeing everything in 
that parent project.properties file.

But doing a 'java -jar submodule.jar' at the command line throws a 
FileNotFoundException because it now *can't* find 
'resources/project.properties'.

Since I need these JARs to be truly "fat" (standalone) I don't even want to 
bother figuring out how to make the call from a different directory, or with a 
-cp <classpath>, etc.

So -

Do I need to move the <build><plugins><plugin> down into each sub-module's POM?

And if so, how do I tell it to include the parent's 
'resources/project.properties'?

.....

2. This one is a little tricky, I think...

A very simplified version of my pipeline looks something like:

1. 'initialize' route
2. 'polling' route
3. 'processing' route

The 'polling' route does *not* start automatically.  The 'initialize' route 
does a bunch of stuff, and then it uses "controlbus" to start the 'polling' 
route - and off we go, polling & processing.

But now I want to do something weird based on how we call this submodule.jar:

1. if no args are passed to the jar, then start 'initialize' and let it run as 
usual.
2. if some args are passed, create an Exchange body, and call the 'processing' 
route.  I.e. don't start any polling; it's just a "one and done".

So basically the question boils down to:

In MyApp's main(), after doing SpringApplication.run(MyApp.class, args) to 
start everything up, how do I:

Get the CamelContext and then either *start* the 'initialize' route or call the 
'processing' route.

Actually, if I can get the CamelContext, I know how to get a ProducerTemplate 
to call the 'processing' route.

But I really don't know how to *start* a route.

.....

Ok, that's it.

Thank you if you've read this far!

Stay safe!

Reply via email to