Spring Cloud Stream Tutorial (iv) Consumer groups

Source: Internet
Author: User

Although the publish subscription model can easily connect applications through shared themes, the ability to scale by creating multiple instances of a given application is equally important. When doing so, different instances of the application are placed in a competing consumer relationship where only one instance is expected to process the given message.

Spring Cloud Stream simulates this behavior through the concept of a consumer group. (The Spring Cloud Stream consumer group is similar to and inspired by the Kafka consumer group.) Each consumer binding can use Spring.cloud.stream.bindings. Group property to specify the name of the groups. For the consumer shown, this property will be set to Spring.cloud.stream.bindings: Group=hdfswrite or Spring.cloud.stream.bindings. Group=average.

SCST Group
Figure 7. Spring Cloud Stream consumer group
All groups that subscribe to a given target receive a copy of the published data, but only one member of each group receives the given message from that destination. By default, when a group is not specified, Spring Cloud stream assigns the application to an anonymous, independent, individual member consumer group that publishes the subscription relationship with all other consumer groups.

Resistant to Durability

A meaningful application pattern in line with spring Cloud Stream, consumer group subscriptions are persistent. That is, the binding implementation ensures that group bookings are persistent, and once you have created at least one subscription for a group, the group will receive messages even if all the applications in the group are stopped.

Attention
Anonymous subscriptions are inherently non-durable. For some binder implementations, such as RABBITMQ, you can have subscriptions for non-persistent groups.

Typically, when you bind an app to a given destination, it's a good idea to always specify a consumer group. When you extend a spring Cloud stream application, you must specify a consumer group for each input binding. This prevents instances of the application from receiving duplicate messages (unless this behavior is required, which is unusual).

Spring Cloud Stream Tutorial (iv) Consumer groups

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.