简体   繁体   English

如何使用 apache camel 将批处理消息发送到 sqs 队列

[英]How to send batch message to a sqs queue using apache camel

I have a rest api in apache camel.我在 apache 骆驼中有一个 rest api。 I wrote a code like so to send a batch message to sqs using apache camel following their documentation.我按照他们的文档编写了这样的代码,使用 apache camel 向 sqs 发送批处理消息。

 .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&region=us-east-1&operation=sendBatchMessage")
                    .endRest()

But this is returning a java.lang.NullPointerException .但这是返回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?还有其他方法可以使用 apache 骆驼向 sqs 发送批处理消息吗?

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这是一个集成测试: 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或者,您可以直接将 SendBatchRequest Pojo 作为正文传递: 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这在文档中有所说明: 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.谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM