Hi,

Thank you! I'm new to the Camel 3 API, can you please point me how can I load a route programmatically if I have a yaml or xml String (or Stream/Reader)?

Regarding the ticket, loading the new files after the startup, renaming the route files and deleting them would also be a useful development feature. Currently it works independently from the initial load, so it does re-load all of the routes it encounters under the base directory, but the pattern it uses to choose which files to (re/un)load follows the different syntax and even the directory base is different.

A jira ticket that I would file would require a developer-friendly "fileReload"-true-false configuration parameter, that would try to use the same pattern that the "include" configuration uses, if it is a "file" one. I can imagine it is not a trivial development for a rarely used development feature and is likely to be  marked as "will not implement" so let's leave it as it is.

On 18.05.2023 09:06, Claus Ibsen wrote:
On Wed, May 17, 2023 at 10:59 PM Fyodor Kravchenko <feddkr...@hotmail.com>
wrote:

Hi,

I'm integrating Camel into my application, or better say, application
platform, that may run different arbitrary Camel routes for integration,
and I'd like to provide an ability for a developer who makes
applications for this platform to edit the routes during the
development. I'm already monitoring the filesystem for other artifact
edits, so If there is an API to reload an individual route taken from a
file I might use that.

I've considered to use a separate Camel standalone or as a containerized
service that I've noticed the project is encouraging now, but this would
require me to develop some protocol to interact with my platform during
its lifecycle. For Camel 2 I managed to instantiate xml snippets to
custom Processors but the API has changed and this Main load-reload
function seemed to do what I want for Camel 3.


Okay so for making the reload respect only already loaded files, then we
can match the "changed file event" form the JDK
and match if it was previously loaded or not. And then skip it if not.

Then users can turn this on via some new option (maybe name it only
existing files, or some better name? ).
withRoutesReloadOnlyExistingFiles(true)


You are welcome to create a JIRA ticket for that.



On 17.05.2023 22:58, Claus Ibsen wrote:
Hi

What is your goal with this?

The reload stuff is for development and not a production app server to
"redeploy apps" or any sort of that.
The intention is that you work on a single application.

The reload is using Java APIs for "change file events" and this does not
support an ANT style way and whatnot.


On Wed, May 17, 2023 at 8:45 PM Fyodor Kravchenko <feddkr...@hotmail.com

wrote:

I'm sorry please disregard my previous ramblings, moving the "deploy"
directory to the working directory of the java app did the "include"
trick. It worked without the "file:" prefix because it was looking into
the "target" directry which was the classpath.. My fault.

However, the additional question remains: how do I make it _reload_ what
it loaded previosly, without catching the extra *.yaml files that may be
located in the wrong directories?

I'm trying this,

           Main main = new Main();


main.configure().withRoutesIncludePattern("file:deploy/**/PRIVATE/EXCHANGE/*.yaml");
           main.configure().withRoutesReloadEnabled(true);
           main.configure().withRoutesReloadDirectory("deploy");
           main.configure().withRoutesReloadDirectoryRecursive(true);
//
main.configure().withRoutesReloadPattern("**/PRIVATE/EXCHANGE/*.yaml");
// main.configure().withRoutesReloadPattern("PRIVATE/EXCHANGE/*.yaml");
           main.configure().withRoutesReloadPattern("*.yaml");
           main.configure().withRoutesReloadRemoveAllRoutes(true);
           main.run();

but this will catch and load any .yaml file under the "deploy"
directory, event those that wasn't loaded at startup, when I touch any
of the yamls.

Any tips on reloading patterns?

Thank you!

On 17.05.2023 21:06, Fyodor Kravchenko wrote:
Hi, thanks but this

.............................
Netbeans uses the following command to run the program:

cd /home/fedd/NetBeansProjects/camelmaintry;
JAVA_HOME=/home/fedd/Programs/graalvm-ce-java19-22.3.0
/snap/netbeans/76/netbeans/java/maven/bin/mvn -Dexec.vmArgs=
"-Dexec.args=${exec.vmArgs} -classpath %classpath ${exec.mainClass}
${exec.appArgs}" -Dexec.appArgs=
-Dexec.mainClass=camelmaintry.CamelMainTry
-Dexec.executable=/home/fedd/Programs/graalvm-ce-java19-22.3.0/bin/java
org.codehaus.mojo:exec-maven-plugin:3.1.0:exec

(nothing special in the "exec.mainClass" and other placeholders there)

I can't grasp how to make it look into this pattern:

deploy/**/PRIVATE/EXCHANGE/*.yaml

Thanks!
--fedd

On 17.05.2023 20:15, Claus Ibsen wrote:
Hi

Okay for file system, you should favour prefixing with file:


main.configure().withRoutesIncludePattern("file:deploy/customer/PRIVATE/EXCHANGE/*.yaml");

On Wed, May 17, 2023 at 3:53 PM Fyodor Kravchenko
<feddkr...@hotmail.com>
wrote:

Hi,

I'm trying to load the routes from the file system directly, it's
Camel
3.20.4, and it's java 19 from the GraalVM distribution running on
Ubuntu
22.04. The fact it sees the file when no wildcard is present tells me
that I'm missing something in the wildcards and the docs.

Thank you!

--fedd

(sorry for the late response, only now I've got the rejection
notification for the html-formatted email)

On 15.05.2023 11:01, Claus Ibsen wrote:
Hi

Are you loading these files from classpath or file system directly.
And what Camel version do you use



On Sun, May 14, 2023 at 5:39 PM Fyodor Kravchenko
<feddkr...@hotmail.com

wrote:

Hello,

in my little test I'm trying the following,


public class CamelMainTry {
         public static void main(String[] args) throws Exception {
             Main main = new Main();
//        this works but I need to catch more
//


main.configure().withRoutesIncludePattern("deploy/customer/PRIVATE/EXCHANGE/*.yaml");
//        these don't work:'
//


main.configure().withRoutesIncludePattern("deploy/**/PRIVATE/EXCHANGE/*.yaml");

main.configure().withRoutesIncludePattern("deploy/*/PRIVATE/EXCHANGE/*.yaml");
             main.run();
         }
}

my files are located:

deploy/customer/PRIVATE/EXCHANGE/cust.yaml

deploy/register/bank/PRIVATE/EXCHANGE/reg.yaml

So there could be more directories in the middle; however it
doesn't
substitute even one.

The Ant-style (or what I'm thinking the Ant style) pattern doesn't
seem
to catch multiple directories. If I specify the directory
explicitly it
works, but I need it to locate the routes in dozens of directories.

How do I fix it?

(While we're at it I would also like to make it reload on the fly
for
the testing purposes, not all of the .yaml files but restricting
it to
my directory structure)

Thanks!

--fedd




Reply via email to