如何配置Azure Service Bus以批量发送消息?
目的是消耗从Kafka并重定向到Azure Service Bus的记录。每次调查Kafka主题时,可以在调试时配置Kafka消费者并确认数千条消息。
另一方面,Azure Service Bus将始终发布一条消息。因此,当此集成运行时,Kafka日志将表明收到了数千条消息,然后Azure Service Bus Logs将迭代每次发送到队列的每个消息。在迭代中,这需要几分钟的时间,从而大大降低了过程。
public class SampleKafkaConsumer extends RouteBuilder {
@Override
public void configure() throws Exception {
log.info("About to start route: Kafka Server -> Log ");
from("kafka:{{consumer.topic}}?brokers={{kafka.host}}:{{kafka.port}}"
+ "&maxPollRecords={{consumer.maxPollRecords}}"
+ "&consumersCount={{consumer.consumersCount}}"
+ "&seekTo={{consumer.seekTo}}"
+ "&groupId={{consumer.group}}"
+ "&lingerMs={{consumer.lingerMs}}"
+ "&producerBatchSize={{consumer.producerBatchSize}}"
+ "&saslJaasConfig={{consumer.saslJaasConfig}}"
+ "&saslMechanism={{consumer.saslMechanism}}"
+ "&securityProtocol={{consumer.securityProtocol}}")
.routeId("Kafka")
.to("azure-servicebus:topic?connectionString={{producer.connectionString}}&producerOperation=sendMessages");
}
}
关于如何处理这个的见解吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Azure Service Bus文档试图暗示的正确解决方案是将结果作为对象或消息列表批量,并将其传递到Azure生产者中。
在apache骆驼中这样做的关键是使用。这是在下面的代码中具有完成间隔的夫妇,允许管道将消息串在一起并分批发送到服务总线。
The right solution that the Azure Service Bus docs were attempting to allude to is to batch up the results as a list of objects or messages and pass that into the Azure producer.
The key to do this in Apache Camel is to use an Aggregator. This, couple with a completion interval in the code below allows the pipe to bunch up messages together and send to the Service Bus in batches.