i recently had a question about AWS and Camel but finally i fought my way through. Now the application seems to work however i am getting a very strange exception.
First of all my App is divided in two EC2 Instances. Instance one gets the ISBN of the top 10 books from an Amazon RSS Feed and stores it into an. Here is the Code Snippet.
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();
}
Instance two is responsible for reading out the SQS as first operation and finally get additional Book information from oder Booklibraries in the WWW what is no problem, and finally build a RSS Feeder which was no problem too.
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" + "®ion=eu-west-1");
}
});
context.start();
Thread.sleep(10000);
context.stop();
}
The problem is now the strange exception, which i dont understand and besides SQS is NOT deleting the messages from my queue , however the api sais that the deleteAfter Read is on 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 - Error occurred during deleting message.. Caused by: [com.amazonaws.AmazonServiceException - The request must contain the parameter MessageHandle.] Status Code: 400, AWS Service: AmazonSQS, AWS Request ID: 0655aa05-ad6f-5571-a83d-e34cc7196343, AWS Error Code: MissingParameter, AWS Error Message: The request must contain the parameter MessageHandle.
The application works but i cant delete any messages in the queue and i dont know why, do i require some additional security credentials ?
Anyhow thanks for help
This error is caused by a null value for the message handle that the Camel SQS endpoint does not find in the output headers. Probably a check should be added and a warning logged when this happens...
To solve, you must ensure that headers set by the SQS producer are passed along all to the end of the route: if you set a new header somewhere, you must also copy the ones from the input, otherwise they are lost.
I wasn't sure how the above would be implemented so this piece of code grabs the Header required and sets it back up at the end.
from("aws-sqs://aqueue")
.setProperty(SqsConstants.RECEIPT_HANDLE, header(SqsConstants.RECEIPT_HANDLE))
...
.setHeader(SqsConstants.RECEIPT_HANDLE, exchangeProperty(SqsConstants.RECEIPT_HANDLE));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With