apache-camelapache-camel-aws

Understanding Apache Camel routing for Amazon SQS


I have an SQS queue. The objective that I am looking to accomplish is to filter message based upon message attributes and delete the same if it matches the filter criteria. So I have a function in Java which looks something like this

public String getUri(){
    String uri = String.format("aws-sqs://%s?accessKey=%s&secretKey=%s&attributeNames=test&deleteIfFiltered=true",queueUrl,key,secret)
    return uri;
}

Post this I am calling this function

public Builder extends RouteBuilder{

    @Override
    public void configure(){
        try{
            from(getUri())
            .setHeader()
            ...
        }

    }

It looks like the route that is building is not able to delete the message.


Solution

  • You need to do as in the documentation says: https://camel.apache.org/components/latest/aws2-sqs-component.html

    about the deleteIfFiltered option.

    You need to set the exchange property (not header) with key CamelAwsSqsDeleteFiltered to true.

    See the docs and this example: https://camel.apache.org/components/latest/aws2-sqs-component.html#_jms_style_selectors