I'm migrating a JBoss EAP application to Quarkus. My application has multiple implementations of the same REST service interface for failover/fallback scenarios:
ManagerClientImpl- Primary HTTP client (calls external service)ManagerClientBackup- Local fallback implementation
Both classes implement the same interface:
@Path("/rate")
public interface Service {
@GET
@Path("/convert")
@Produces("application/json")
Amount convert(@QueryParam("param") String param, ...);
}
The ErrorWhen building with Quarkus, I get:
[ERROR] GET /rate is declared by:
[ERROR] ManagerClientImpl#convert [ERROR] ManagerClientBackup#convert
[ERROR] at io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor.checkForDuplicateEndpoint(ResteasyReactiveProcessor.java:1504) [ERROR] at io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor.setupEndpoints(ResteasyReactiveProcessor.java:731)
In JBoss, this configuration works fine.
Cannot significantly change existing architecture. Both implementations must exist in the JAR (for producer pattern which is needed for our failover(backup) strategy)
Update:
I have tried 2 solution which didnt work for my case
1.@EndpointDisabled - Doesn't prevent REST endpoint discovery, only disables at runtime
- @Alternative + @Priority + BuildProperty annotation - This will work but endpoints discovered at build time
Is there a way in Quarkus to Keep both implementations as REST endpoints in the build Have only ONE actually registered/available at runtime based on CDI producer selection or we if we have any configuration in which I can change it in run time so that when we need to backup solution I can switch to that in run time.
Stack trace:
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:3.20.1.redhat-00003:build (default) on project acs-quarkus-authentication-service: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [ERROR] [error]: Build step io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor#setupEndpoints threw an exception: [ERROR] GET /useragent is declared by : [ERROR] com.worldline.acs.utils.babel.client.useragent.UserAgentParserClientBackup#parse consumes *, produces application/json [ERROR] com.worldline.acs.utils.babel.client.useragent.UserAgentParserClientImpl#parse consumes *, produces application/json [ERROR] DELETE /proxy/v2 is declared by : [ERROR] com.worldline.acs.hubs.mock.RestProxyManagerV2MockImpl#deleteAuthentication consumes application/json, produces application/json [ERROR] com.worldline.acs.hubs.client.proxyImpl.RestProxyBackupManagerV2Impl#deleteAuthentication consumes application/json, produces application/json [ERROR] GET /iptolocation is declared by : [ERROR] com.worldline.acs.utils.babel.client.iptolocation.IpToLocationManagerClientBackup#locate consumes *, produces application/json [ERROR] com.worldline.acs.utils.babel.client.iptolocation.IpToLocationManagerClientImpl#locate consumes *, produces application/json [ERROR] [ERROR] at io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor.checkForDuplicateEndpoint(ResteasyReactiveProcessor.java:1504) [ERROR] at io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor.setupEndpoints(ResteasyReactiveProcessor.java:731) [ERROR] at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732) [ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:255) [ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654) [ERROR] at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594) [ERROR] at java.base/java.lang.Thread.run(Thread.java:840) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:499) [ERROR] ->