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

Auto-Configuration for Camel-Master Service-Selector #6488

Open
anchialas opened this issue Sep 19, 2024 · 1 comment
Open

Auto-Configuration for Camel-Master Service-Selector #6488

anchialas opened this issue Sep 19, 2024 · 1 comment
Labels
area/master bug Something isn't working

Comments

@anchialas
Copy link

Bug description

We have multiple Camel-Master Service Providers active in our Quarkus camel app with

  • Quarkus v3.8.6
  • Camel-Quarkus v3.8.3
  • Camel v4.4.3

Therefore we would like to replace the default SelectSingle selector [1] with the SelectByOrder implementation. For this we use the property camel.component.master.service-selector. Since an instance is expected as the value, we have also written a simple converter:

@Converter
public class ClusterSelectorConverter {
    @Converter
    public CamelClusterService.Selector convert(String selectorClass) {
        try {
            return (CamelClusterService.Selector)Class.forName(selectorClass).getConstructor().newInstance();
        } catch (Exception ex) {
            throw new IllegalStateException(ex);
        }
    }
}

This all works, but the auto-configuration mechanism [2] takes effect too late: the master component has already been initialized with the default selector [3].

How can the selector be configured “correctly”?

Thank you!

[1] org.apache.camel.support.cluster.ClusterServiceSelectors#DEFAULT_SELECTOR
[2] MainHelper.setPropertiesOnTarget:323
[3] MainHelper.setPropertiesOnTarget:303

@anchialas anchialas added the bug Something isn't working label Sep 19, 2024
@jamesnetherton
Copy link
Contributor

How can the selector be configured “correctly”?

You could get a handle on the master component within a CDI observer and use setServiceSelector to pass in your custom selector. See example here:

https://camel.apache.org/camel-quarkus/next/user-guide/configuration.html#_cdi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/master bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants