Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camel quarkus disable auto route discovery not working #1816

Closed
heyplusyou opened this issue Sep 22, 2020 · 6 comments · Fixed by #1817
Closed

Camel quarkus disable auto route discovery not working #1816

heyplusyou opened this issue Sep 22, 2020 · 6 comments · Fixed by #1817
Assignees
Milestone

Comments

@heyplusyou
Copy link

heyplusyou commented Sep 22, 2020

Hi all,

I am currently setting up a camel project based on quarkus and I would like to handle the route activation based on DB entries at runtime. We created a couple of routes in DSL by extending the RouteBuilder and it works fine with route auto discovery.

But to implement the DB and runtime activation I would need to disable the auto discovery. Is there a way to do this?

I found the option

  • quarkus.camel.main.routes-discovery.enabled=false

But I still finds the RouteBuilders and starts them during startup.

Quarkus: 1.8.0
Camel Quarkus: 1.1.0

application.properties

quarkus.camel.routes-discovery.enabled=false
quarkus.camel.routes-discovery.exclude-patterns="de/*"

management.endpoints.web.exposure.include=hawtio,jolokia

# DATASOURCE
db.host=${DB_HOST:localhost}
db.port=${DB_PORT:5432}
db.name=${DB_NAME:esb}
quarkus.datasource.url=jdbc:postgresql://${db.host}:${db.port}/${db.name}
quarkus.datasource.driver=org.postgresql.Driver
quarkus.datasource.username=${DB_USERNAME:postgres}
quarkus.datasource.password=${DB_PASSWORD:postgres}

log

2020-09-22 08:13:42,352 INFO  [org.apa.cam.qua.cor.CamelBootstrapRecorder] (Quarkus Main Thread) bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime
2020-09-22 08:13:42,365 INFO  [org.apa.cam.mai.DefaultConfigurationConfigurer] (Quarkus Main Thread) Using HealthCheckRegistry: org.apache.camel.impl.health.DefaultHealthCheckRegistry@5cee50ae
2020-09-22 08:13:42,382 INFO  [org.apa.cam.qua.mai.CamelMainRoutesCollector] (Quarkus Main Thread) Loading additional Camel XML route templates from: classpath:camel-template/*.xml
2020-09-22 08:13:42,389 INFO  [org.apa.cam.man.JmxManagementStrategy] (Quarkus Main Thread) JMX is enabled
2020-09-22 08:13:42,445 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Quarkus Main Thread) Apache Camel 3.5.0 (camel-1) is starting
2020-09-22 08:13:42,572 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Quarkus Main Thread) StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
2020-09-22 08:13:42,572 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Quarkus Main Thread) Using HealthCheck: camel-microprofile-health
2020-09-22 08:13:42,680 INFO  [org.apa.cam.imp.eng.InternalRouteStartupManager] (Quarkus Main Thread) Route: testroute started and consuming from: file://XXXXXX
2020-09-22 08:13:42,681 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Quarkus Main Thread) Total 1 routes, of which 1 are started
2020-09-22 08:13:42,681 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Quarkus Main Thread) Apache Camel 3.5.0 (camel-1) started in 0.236 seconds

Many thanks!

@lburgazzoli
Copy link
Contributor

@heyplusyou how did you define the route ? I mean it's just a RouteBuilder class or annotate with a CDI annotation ?

@heyplusyou
Copy link
Author

@lburgazzoli defined with @ApplicationScoped

see below

@ApplicationScoped
public class TestRouteBuilder extends RouteBuilder {

    @Inject
    TestConfig testConfig;

    @Override
    public void configure() {
        onException(Exception.class)
                .handled(true)
                .log("${headers.CamelFileName} could not be processed")
                .log("Error:")
                .log("${exception.message}")
                .log("${exception.stacktrace}")
                .to("file:" + testConfig.broilking_directory_error);

        from("file:" + testConfig.broilking_directory_in + "?include=.*\\.csv&noop=false")
                .autoStartup(ProfileManager.getActiveProfile().equals(RouteProfiles.TEST.getUIName()))
                .log("Processing: ${headers.CamelFileName}")
                .process(new RoconCSVProcessor(broilKingConfig))
                .log("${headers.CamelFileName} successfully processed")
                .to("file:" + testConfig.broilking_directory_out);
    }
}

@lburgazzoli
Copy link
Contributor

ok, now I see what the problem is, working on a fix.
In the meantime, I think if you remove the ApplicationScoped it should not end up being loaded.

@lburgazzoli lburgazzoli self-assigned this Sep 22, 2020
@lburgazzoli
Copy link
Contributor

@heyplusyou btw, thinking about it a little bit more, unless you want to add the route yourself, if you only want to activate a route upon a condition, you can disable route's auto-startup as you are already doing, isn't that enough ?

@heyplusyou
Copy link
Author

ok, now I see what the problem is, working on a fix.
In the meantime, I think if you remove the ApplicationScoped it should not end up being loaded.

I can confirm when I remove the @ApplicationScoped then its not starting automatically. But of course would be great to control it via properties

@heyplusyou btw, thinking about it a little bit more, unless you want to add the route yourself, if you only want to activate a route upon a condition, you can disable route's auto-startup as you are already doing, isn't that enough ?

Yes and no, my idea was to start the route with different attributes e.g. for test environment I can just switch the directories. But its a good point, let me try it it.

@lburgazzoli
Copy link
Contributor

For most of the things you can probably rely on properties I guess but let us know so we can eventually enhance what we do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants