Cannot delete message from SQS Camel Route

Recently, I had a question about AWS and Camel , but finally I made my way. Now the application works, however I get a very strange exception.

First of all, my application is divided into two instances of EC2. One copy gets the ISBN of the top 10 books from Amazon's RSS feed and stores it in. Here is a snippet of code.

public static void main(String[] args) throws Exception { CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { public void configure() { from( "rss:http://www.amazon.de/gp/rss/bestsellers/books/ref=zg_bs_books_rsslink?splitEntries=false") .split() .method("RssSplitter", "split") .process(new Dummy()) .setProperty("isbn", simple("${body}")) .to("aws-sqs://bookz_sqs?accessKey=acceskey&secretKey=secretKey"); } }); context.start(); Thread.sleep(10000); context.stop(); } 

The second copy is responsible for reading SQS as the first operation, and finally gets additional information about the book from other libraries in the WWW, which is not a problem, and finally create an RSS feed, which was also not a problem.

 public static void main(String[] args) throws Exception { /* * Here the sqs camel route gets the ISBN out of the queues and stores it in S3. */ CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { public void configure() { from("aws-sqs://bookz_sqs" + "?accessKey=accessKey" + "&secretKey=secretKey").process(new DynamicIsbnEnrich()).process( new DynamicIsbndbEnrich()).process(new DynamicOpLibEnrich()).setHeader(S3Constants.KEY, simple("${property.isbn}")).to( "aws-s3://bookz" + "?accessKey=accesKey" + "&secretKey=secretKEy" + "&region=eu-west-1"); } }); context.start(); Thread.sleep(10000); context.stop(); } 

Currently, the problem is a strange exception that I don’t understand, and in addition, SQS does NOT delete messages from my queue, however api sais that deleteAfter Read is set to true by default.

2012-12-17 19: 45: 08,335 [Camel (camel-1) thread # 0 - aws-sqs: // team09bookz_sqs] WARN org.apache.camel.component.aws.sqs.SqsConsumer - An error occurred while deleting the message .. Reason: [com.amazonaws.AmazonServiceException - the request must contain the MessageHandle parameter.] Status code: 400, AWS Service: AmazonSQS, AWS Request ID: 0655aa05-ad6f-5571-a83d-e34cc7196343, AWS Error code: MissingParameter, AWS Message error message: The request must contain the MessageHandle parameter.

The application works, but I can’t delete any messages in the queue, and I don’t know why, do I need additional security credentials?

Anyway thanks for the help

+4
source share
2 answers

This error is caused by a null value for the message descriptor that the Camel SQS endpoint does not find in the output headers. You probably need to add a check and warn when this happens ...

To decide, you need to make sure that the headers set by the SQS manufacturer are transmitted along the entire route to the end of the route: if you set a new header somewhere, you must also copy them from the input, otherwise they will be lost.

+4
source

I was not sure how this is implemented above, so this piece of code grabs the required header and sets it at the end.

 from("aws-sqs://aqueue") .setProperty(SqsConstants.RECEIPT_HANDLE, header(SqsConstants.RECEIPT_HANDLE)) ... .setHeader(SqsConstants.RECEIPT_HANDLE, exchangeProperty(SqsConstants.RECEIPT_HANDLE)); 
0
source

All Articles