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-18152: implement auto-configuration for the adapters #8046

Merged
merged 1 commit into from Jul 27, 2022

Conversation

orpiske
Copy link
Contributor

@orpiske orpiske commented Jul 26, 2022

No description provided.

@github-actions
Copy link
Contributor

⚠️ This PR changes Camel components and will be tested automatically.

@davsclaus
Copy link
Contributor

Its a bit wrong when there are 2 generated files for the same thing. You need for @JdkService to have a sub path I think, eg @JdkService("resume/file")

Or you can create a special annotation that extends @JdkService that setup this correct, we have done this for some others, then you can use @ResumeAdapter("file") etc as annotation.

@orpiske
Copy link
Contributor Author

orpiske commented Jul 26, 2022

Its a bit wrong when there are 2 generated files for the same thing. You need for @JdkService to have a sub path I think, eg @JdkService("resume/file")

Or you can create a special annotation that extends @JdkService that setup this correct, we have done this for some others, then you can use @ResumeAdapter("file") etc as annotation.

Oh, thanks for catching it.

One of the files in the camel-file shouldn't be there as it is a leftover from a previous attempt. 🤦🏽‍♂️

What I am trying to achieve here is that it needs to be able to differentiate between different configs based on the consumer so that it loads the adapter that is appropriate for that component. However, there are some components (like the DB-based ones) that have a shared adapter because they do +/- the same thing.

Tomorrow I'll clean it up.

@github-actions
Copy link
Contributor

✔️ Finished component verification: 0 component(s) test failed out of 7 component(s) tested

@orpiske
Copy link
Contributor Author

orpiske commented Jul 27, 2022

@davsclaus I removed the duplicated files, so now it should be the real thing. I am thinking about creating the "ResumeAdapter" annotation you mentioned. Not necessarily on this PR, but as a follow up, since there's a chance it will need greater flexibility in the future.

@github-actions
Copy link
Contributor

❌ Finished component verification: 1 component(s) test failed out of 7 component(s) tested

@orpiske
Copy link
Contributor Author

orpiske commented Jul 27, 2022

Couchdb is known to be broken on GH actions, so we are good to merge despite the test failure.

@orpiske orpiske merged commit c312727 into apache:main Jul 27, 2022
@orpiske orpiske deleted the camel-18152 branch August 16, 2022 11:26
@ColdFireIce
Copy link

HI @orpiske ,
after I switched to version 3.19.0 (with this change) My route to process some files is no longer working:

Error starting consumer while taking leadership. Caused by: [java.lang.NullPointerException - Cannot invoke "org.apache.camel.resume.ResumeStrategy.setAdapter(org.apache.camel.resume.ResumeAdapter)" because "this.resumeStrategy" is null]

@Component
public class LocalDirectoryWatcher extends RouteBuilder {

    @Override
    public void configure() {
        from("{{route.in}}")
                .process(this::exchange);
    }

    void exchange(Exchange exchange) {
    ...
    }

route.in is route.in: master:localimport:file:/some-directory-patch

Other routes that just do a from("{{foo.route.in}}").to("{{foo.route.out}}"); work fine.

Is there something I'm missing?

@orpiske
Copy link
Contributor Author

orpiske commented Oct 6, 2022

HI @orpiske , after I switched to version 3.19.0 (with this change) My route to process some files is no longer working:

Error starting consumer while taking leadership. Caused by: [java.lang.NullPointerException - Cannot invoke "org.apache.camel.resume.ResumeStrategy.setAdapter(org.apache.camel.resume.ResumeAdapter)" because "this.resumeStrategy" is null]

@Component
public class LocalDirectoryWatcher extends RouteBuilder {

    @Override
    public void configure() {
        from("{{route.in}}")
                .process(this::exchange);
    }

    void exchange(Exchange exchange) {
    ...
    }

route.in is route.in: master:localimport:file:/some-directory-patch

Other routes that just do a from("{{foo.route.in}}").to("{{foo.route.out}}"); work fine.

Is there something I'm missing?

Thanks for the report. Please, can you share the whole stack trace? Also feel free to open a ticket on our Jira with all the details, so I can take a look at it.

@ColdFireIce
Copy link

Hi, sure. Here ist the stacktrace:

java.lang.NullPointerException: Cannot invoke "org.apache.camel.resume.ResumeStrategy.setAdapter(org.apache.camel.resume.ResumeAdapter)" because "this.resumeStrategy" is null
	at org.apache.camel.component.master.MasterConsumer.onLeadershipTaken(MasterConsumer.java:147)
	at org.apache.camel.component.master.MasterConsumer$LeadershipListener.leadershipChanged(MasterConsumer.java:179)
	at org.apache.camel.support.cluster.AbstractCamelClusterView.lambda$fireLeadershipChangedEvent$4(AbstractCamelClusterView.java:127)
	at org.apache.camel.support.cluster.AbstractCamelClusterView.lambda$doWithListener$3(AbstractCamelClusterView.java:118)
	at org.apache.camel.util.concurrent.LockHelper.doWithReadLock(LockHelper.java:34)
	at org.apache.camel.support.cluster.AbstractCamelClusterView.doWithListener(AbstractCamelClusterView.java:111)
	at org.apache.camel.support.cluster.AbstractCamelClusterView.fireLeadershipChangedEvent(AbstractCamelClusterView.java:125)
	at org.apache.camel.component.kubernetes.cluster.KubernetesClusterView.lambda$doStart$0(KubernetesClusterView.java:115)
	at org.apache.camel.component.kubernetes.cluster.lock.TimedLeaderNotifier.checkAndNotify(TimedLeaderNotifier.java:168)
	at org.apache.camel.component.kubernetes.cluster.lock.TimedLeaderNotifier.lambda$refreshLeadership$0(TimedLeaderNotifier.java:85)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

I try to find the time to create a ticket in the JIRA (must create login first).

Thanks for looking into it

@orpiske
Copy link
Contributor Author

orpiske commented Oct 6, 2022

@ColdFireIce I hope you don't mind, but I went ahead and created the ticket, so I can fix and backport this: https://issues.apache.org/jira/browse/CAMEL-18594

@ColdFireIce
Copy link

Hey @orpiske, Thank you. I surely don't mind :)
Thank you for the quick fix.

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