[Stream] SAC Active and Waiting Comumers both must be able to listen event. #11184
-
I'm not sure this repository is suitable to discuss this topic. in the https://github.com/rabbitmq/rabbitmq-stream-java-client, there is I expected to any update event(regardless of active, waiting) will invoke but, it invoked val consumer = env.consumerBuilder()
.name("test")
.stream("playground")
.singleActiveConsumer()
.messageHandler { context, message ->
println("offset: ${context.offset()}, message: ${String(message.bodyAsBinary)}")
}
.consumerUpdateListener { ctx ->
println("UpdateListener: $ctx")
OffsetSpecification.last()
}
.build() The above code prints Is it Stream SAC specification that only call active consumer? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 13 replies
-
It's a philosophical question, whether events should be broadcast to all consumers or just the active one if the SAC mode is used. I'd say only the active one. If you want N active consumers then don't use the SAC feature. There may be situation where some metadata updates exposed to the user (your app) might be worth distributing to all consumers but you have to come up with a specific example. SAC tries to create an illusion that there's only one consumer online. |
Beta Was this translation helpful? Give feedback.
-
From a team member who was one of the key contributors to the SAC feature:
|
Beta Was this translation helpful? Give feedback.
-
In a single active consumer group, a consumer is considered inactive by default, until it receives a notification that it is active. Then an active consumer can receive a notification that it becomes inactive. A consumer gets to decide where to start consuming from when it becomes active: it responds to the notification with an offset specification and the broker will use it to initialize the message flow at the appropriate location in the stream. It can get the offset notification from any data source (RabbitMQ with server-side offset tracking or a custom database). An active consumer has a chance to store the last offset it processed when it gets a notification that it becomes inactive. This way the new active consumer will be able to resume where the former active consumer left off. The frequency of the consumer update notification is meant to make the system work, not to broadcast events to consumers. We do not plan on changing this unless there is a good reason to do it. |
Beta Was this translation helpful? Give feedback.
In a single active consumer group, a consumer is considered inactive by default, until it receives a notification that it is active. Then an active consumer can receive a notification that it becomes inactive.
A consumer gets to decide where to start consuming from when it becomes active: it responds to the notification with an offset specification and the broker will use it to initialize the message flow at the appropriate location in the stream. It can get the offset notification from any data source (RabbitMQ with server-side offset tracking or a custom database).
An active consumer has a chance to store the last offset it processed when it gets a notification that it becomes inactive.…