I have a rest api in apache camel. I wrote a code like so to send a batch message to sqs using apache camel following their documentation.
.post("sqs-send-batch-message")
.route()
.process(new Processor(){
@Override
public void process(Exchange exchange) throws Exception {
String message = "Hello World";
exchange.getIn().setBody(message);
}
})
.to("aws2-sqs://queueName?accessKey=insert&secretKey=insert®ion=us-east-1&operation=sendBatchMessage")
.endRest()
But this is returning a java.lang.NullPointerException
. This is the way it was given in their documentation. Is there some other way to send batch message to sqs using apache camel?
As reported in the documentation you need to pass an iterable as body. Here is an integration test: https://github.com/apache/camel/blob/master/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerBatchSendIntegrationTest.java
Alternatively you can pass a SendBatchRequest Pojo as body directly: https://github.com/apache/camel/blob/master/components/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Producer.java#L107
This is stated in the documentation: https://camel.apache.org/components/latest/aws2-sqs-component.html#_send_batch_message
I don't know where you read about that way of send batch message. Can you please report an issue if the documentation is somewhere incorrect? Thanks.