[英]Can a Spring Cloud Stream Kinesis consumer group be sent by a non-Spring producer?
In our environment, we have a producer that is not a Spring microservice sending Avro messages over Kinesis to a Spring Cloud microservice.在我们的环境中,我们有一个生产者,它不是 Spring 微服务,它通过 Kinesis 向 Spring Cloud 微服务发送 Avro 消息。 My question is how can the non-Spring producer add the consumer group message header to each message so that the Spring microservice can scale up to more than one instance, ensuring that the Spring microservices do not consume each message more than once?我的问题是非Spring生产者如何给每条消息添加消费者组消息头,让Spring微服务可以扩展到多个实例,保证Spring微服务不会多次消费每条消息?
Can this be done in Kinesis, and if so, are there any code examples anyone can point me to?这可以在 Kinesis 中完成吗,如果可以,是否有任何人可以指点我的代码示例?
I would say "Not clear what you're asking", but I'll try to explain what might be wrong.我会说“不清楚你在问什么”,但我会尽力解释可能有什么问题。
The Consumer Group is an abstraction, well..., for consumers.消费者组是一个抽象,嗯……,对于消费者。 The producer has nothing to know about that abstraction.生产者对这种抽象一无所知。 It's point just send messages to the destination and forget.只需将消息发送到目的地并忘记即可。
One of main goals of the consumer group abstraction is to ensure that message is processed only in one consumer meanwhile there might be more than one consumer in a group.消费者组抽象的主要目标之一是确保消息仅在一个消费者中处理,同时一组中可能有多个消费者。
There is a feature in AWS Kinesis complementing consumer group abstraction. AWS Kinesis 中有一项功能可以补充消费者组抽象。 It is sharding in Kinesis streams.它在 Kinesis 流中进行分片。 With consumer group implementation in Spring Cloud Stream, there is a trick to distribute shards between consumers in a group, so they can be processed in parallel.通过 Spring Cloud Stream 中的消费者组实现,有一个技巧可以在组中的消费者之间分配分片,因此它们可以并行处理。
Here you really can benefit fro sharding saying to your producer to which one to send a record.在这里,您真的可以从分片中受益,告诉您的制作人要将记录发送给哪个人。 See more info about partitionKey
in Kinesis Producer API.在 Kinesis Producer API 中查看有关partitionKey
更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.