Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12934

Camel SQS regression: old code with amazonSQSEndpoint fails

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.22.1
    • Fix Version/s: None
    • Component/s: camel-aws
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      After upgrade from Camel 2.14 to 2.22.1, I have noticed we completely removed support of amazonSQSEndpoint parameter from SqsConfiguration and related classes: https://github.com/apache/camel/commit/adfdda36cd6d4736ee292f13514badd58b2dbe5b#diff-10c0ab07ac9c261a8e9a5c1ce1dd8f4c .

      As a side affect, all previous code where we create SQS endpoint from URL (through DefaultCamelContext.getEndpoint(String uri)) and still pass URL parameter  amazonSQSEndpoint started to fail with validation Exception:

      Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: aws-sqs://SQSTarget?accessKey=...&amazonSQSEndpoint=https%3A%2F%2Fsqs.us-west-2.amazonaws.com&secretKey=... due to: Failed to resolve endpoint: aws-sqs://SQSTarget?accessKey=...&amazonSQSEndpoint=https%3A%2F%2Fsqs.us-west-2.amazonaws.com&secretKey=... due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{amazonSQSEndpoint=https://sqs.us-west-2.amazonaws.com}]
              at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:758)
              at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:80)
              at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:221)
              at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:116)
              at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:122)
              at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:62)
              at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:56)
              at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:562)
              at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:523)
              at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:239)
              at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1343)
              ... 34 more
      Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: aws-sqs://SQSTarget?accessKey=...&amazonSQSEndpoint=https%3A%2F%2Fsqs.us-west-2.amazonaws.com&secretKey=... due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{amazonSQSEndpoint=https://sqs.us-west-2.amazonaws.com}]
              at org.apache.camel.impl.DefaultComponent.validateParameters(DefaultComponent.java:215)
              at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:139)
              at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:711)
              ... 44 more

      It happens because deeper IntrospectionSupport is used to go through SqsConfiguration class setters via reflection to set all SQS parameters. And since setter for amazonSQSEndpoint was removed, this parameter is left unparsed, and later all unparsed parameters are treated as invalid in DefaultComponent.validateParameters.

      Was this behavior intentional? AWS library, which is used underneath, still supports this parameter, it just allows only either region or amazonSQSEndpoint, and amazonSQSEndpoint has priority. From com.amazonaws.client.builder.AwsClientBuilder:

      private void setRegion(AmazonWebServiceClient client) {
              if (region != null && endpointConfiguration != null) {
                  throw new IllegalStateException("Only one of Region or EndpointConfiguration may be set.");
              }
              if (endpointConfiguration != null) {
                  client.setEndpoint(endpointConfiguration.getServiceEndpoint());
                  client.setSignerRegionOverride(endpointConfiguration.getSigningRegion());
              } else if (region != null) {
                  client.setRegion(region);
              } else {
                  final String region = determineRegionFromRegionProvider();
                  if (region != null) {
                      client.setRegion(RegionUtils.getRegion(region));
                  } else {
                      throw new SdkClientException(
                              "Unable to find a region via the region provider chain. " +
                              "Must provide an explicit region in the builder or setup environment to supply a region.");
                  }
              }
          }

      My suggestion:

      1. Return back amazonSQSEndpoint parameter so older code does not fail.
      2. If amazonSQSEndpoint removal was made because of AWS limitations, and both parameters are present, we may just use amazonSQSEndpoint and ignore region, as AWS does, and document this logic.

        Attachments

          Activity

            People

            • Assignee:
              acosentino Andrea Cosentino
              Reporter:
              mshalak Maksym Shalak
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: