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