You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2018/12/30 10:19:00 UTC

[jira] [Commented] (CAMEL-12970) Camel Maven Plugin: false postives with directOrSedaPairCheck

    [ https://issues.apache.org/jira/browse/CAMEL-12970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16730934#comment-16730934 ] 

Claus Ibsen commented on CAMEL-12970:
-------------------------------------

This is because you have a base route which you instantiate a new instance and tempalte the direct endpoints - this is an use-case where the parser cannot check.



> Camel Maven Plugin: false postives with directOrSedaPairCheck
> -------------------------------------------------------------
>
>                 Key: CAMEL-12970
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12970
>             Project: Camel
>          Issue Type: Bug
>    Affects Versions: 2.23.0
>            Reporter: David Sharpe
>            Priority: Minor
>              Labels: camel-maven-plugin
>
> In one of my RouteBuilders I instantiate and include some routes with {{RouteBuilder::includeRoutes}}. When I run {{mvn camel:validate}}, these routes generate the "Sending to non existing direct queue name" error. The routes work though.
> Here is the Route. I can make a smaller example, but I won't if I don't need to.
> {code:java|title=HealthRoute.java}
> import java.sql.Connection;
> import java.sql.SQLException;
> import java.util.HashMap;
> import javax.sql.DataSource;
> import org.apache.camel.BeanInject;
> import org.apache.camel.Exchange;
> import org.apache.camel.Processor;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.json.simple.JsonObject;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> /**
>  * An HTTP service that validates some application configuration properties. The
>  * validation status is returned as simply "true" or "false" with error messages
>  * printed to the log.
>  */
> public class HealthRoute extends RouteBuilder {
>     private static final String ROUTE_CHECK_SUBMIT_ASSESSMENTS_ENDPOINT = "checkSubmitAssessmentsEndpoint";
>     private static final String ROUTE_CHECK_QUERY_ENDPOINT = "checkQueryEndpoint";
>     private static final String DATABASE_REACHABLE = "isDatabaseReachable";
>     @BeanInject(value = "dataSource")
>     private DataSource dataSource;
>     private static final Logger LOGGER = LoggerFactory.getLogger(HealthRoute1.class);
>     @Override
>     public void configure() throws Exception {
>         from("servlet:smoketest?servletName=HealthServlet")
>                 .to("direct:" + ROUTE_CHECK_QUERY_ENDPOINT)
>                 .to("direct:" + ROUTE_CHECK_SUBMIT_ASSESSMENTS_ENDPOINT)
>                 .process(new CheckDatabaseConnection())
>                 .process(exchange -> {
>                     HashMap<String, Object> hashMap = new HashMap<>();
>                     hashMap.put("isQueryEndpointReachable", exchange.getProperty(ROUTE_CHECK_QUERY_ENDPOINT));
>                     hashMap.put("isSubmitAssessmentsEndpointReachable", exchange.getProperty(ROUTE_CHECK_SUBMIT_ASSESSMENTS_ENDPOINT));
>                     hashMap.put(DATABASE_REACHABLE, exchange.getProperty(DATABASE_REACHABLE));
>                     exchange.getIn().setBody(new JsonObject(hashMap).toJson());
>                 })
>                 .setHeader("Content-Type", constant("application/json"));
>         String queryHumanSubjectsUri = getContext().resolvePropertyPlaceholders("{{queryHumanSubjectsUri}}").replaceAll("https?://", "");
>         String submitExternalAssessmentsUri = getContext().resolvePropertyPlaceholders("{{submitExternalAssessmentsUri}}").replaceAll("https?://", "");
>         includeRoutes(new CheckEndpointRoute(ROUTE_CHECK_QUERY_ENDPOINT, queryHumanSubjectsUri));
>         includeRoutes(new CheckEndpointRoute(ROUTE_CHECK_SUBMIT_ASSESSMENTS_ENDPOINT, submitExternalAssessmentsUri));
>     }
>     /**
>      * Smoke tests the availability of a given HTTP resource by issuing a GET
>      * request. If the request throws an exception an error flag is set on the
>      * Exchange.
>      */
>     private static class CheckEndpointRoute extends RouteBuilder {
>         private final String routeId;
>         private final String uri;
>         public CheckEndpointRoute(String routeId, String uri) {
>             this.routeId = routeId;
>             this.uri = uri;
>         }
>         @Override
>         public void configure() throws Exception {
>             from("direct:" + routeId)
>                     .doTry()
>                     .to("https4:"
>                             + uri
>                             + "?sslContextParameters=#sslParameters"
>                             + "&bridgeEndpoint=true"
>                             + "&x509HostnameVerifier=#hostnameVerifier")
>                     .setProperty(routeId, constant(true))
>                     .doCatch(Exception.class)
>                     .to("log:com.cgi.best.HealthRoute?level=ERROR&showCaughtException=true")
>                     .setProperty(routeId, constant(false))
>                     .end();
>         }
>     }
>     /**
>      * Smoke tests the availability of the database by executing a standard
>      * database health query.
>      */
>     private class CheckDatabaseConnection implements Processor {
>         @Override
>         public void process(Exchange exchange) throws Exception {
>             try (Connection connection = dataSource.getConnection()) {
>                 connection.createStatement().execute("select * from dual");
>                 exchange.setProperty(DATABASE_REACHABLE, true);
>             } catch (SQLException ex) {
>                 LOGGER.error("Database test query failed.", ex);
>                 exchange.setProperty(DATABASE_REACHABLE, false);
>             }
>         }
>     }
> }
> {code}
> {code}
> $ mvn camel:validate
> [INFO] Scanning for projects...
> [INFO]
> [INFO] ------------------------------------------------------------------------
> [INFO] Building BestAdapter 1.0-SNAPSHOT
> [INFO] ------------------------------------------------------------------------
> [INFO]
> [INFO] --- camel-maven-plugin:2.23.0:validate (default-cli) @ BestAdapter ---
> [INFO] Detected Camel version used in project: 2.23.0
> [INFO] Validating using Camel version: 2.23.0
> [INFO] Endpoint validation success: (16 = passed, 0 = invalid, 2 = incapable, 0 = unknown components, 0 = deprecated options)
> [INFO] Simple validation success: (3 = passed, 0 = invalid)
> [WARNING] Endpoint pair (seda/direct) validation error at: com.cgi.best.HealthRoute.configure(HealthRoute.java:45)
>         direct:checkQueryEndpoint
>                                 checkQueryEndpoint      Sending to non existing direct queue name
> [WARNING] Endpoint pair (seda/direct) validation error at: com.cgi.best.HealthRoute.configure(HealthRoute.java:45)
>         direct:checkSubmitAssessmentsEndpoint
>                                 checkSubmitAssessmentsEndpoint  Sending to non existing direct queue name
> [WARNING] Endpoint pair (seda/direct) validation error at: com.cgi.best.HealthRoute1.configure(HealthRoute1.java:45)
>         direct:checkQueryEndpoint
>                                 checkQueryEndpoint      Sending to non existing direct queue name
> [WARNING] Endpoint pair (seda/direct) validation error at: com.cgi.best.HealthRoute1.configure(HealthRoute1.java:45)
>         direct:checkSubmitAssessmentsEndpoint
>                                 checkSubmitAssessmentsEndpoint  Sending to non existing direct queue name
> [WARNING] Endpoint pair (seda/direct) validation error: (2 = pairs, 4 = non-pairs)
> [INFO] Duplicate route id validation success (3 = ids)
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 3.030 s
> [INFO] Finished at: 2018-11-30T08:55:31-08:00
> [INFO] Final Memory: 21M/398M
> [INFO] ------------------------------------------------------------------------
> [ERROR] Failed to execute goal org.apache.camel:camel-maven-plugin:2.23.0:validate (default-cli) on project BestAdapter: Endpoint validation success: (16 = passed, 0 = invalid, 2 = incapable, 0 = unknown components, 0 = deprecated options)
> [ERROR] Simple validation success: (3 = passed, 0 = invalid)
> [ERROR] Duplicate route id validation success (3 = ids)
> [ERROR] Endpoint pair (seda/direct) validation error: (2 = pairs, 4 = non-pairs)
> [ERROR] -> [Help 1]
> [ERROR]
> [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
> [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> [ERROR]
> [ERROR] For more information about the errors and possible solutions, please read the following articles:
> [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)