Quick revision
The short answer
We would first inventory the thirty services: their bindings, destinations, groups, and the features they use, such as listener conditions, error channels and custom converters. Each @StreamListener becomes a Consumer or Function bean, each output channel send becomes StreamBridge or a function's return value, and we keep every destination and group name unchanged so Kafka offsets and RabbitMQ queues are reused. We publish a migration guide, migrate one pilot service first, schedule the rest by upgrade urgency, and test each one against real brokers before production.
What to remember
In this answer, we planned the migration of thirty services from the removed annotation model. We inventoried bindings and special features, mapped each @StreamListener to a Consumer or Function bean and each output send to StreamBridge, kept every destination and group unchanged so offsets and queues are reused, piloted one service with a migration guide, scheduled the rest by upgrade urgency, and tested against real brokers before production and before the separate Boot upgrade.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
We would first inventory the thirty services: their bindings, destinations, groups, and the features they use, such as listener conditions, error channels and custom converters. Each @StreamListener becomes a Consumer or Function bean, each output channel send becomes StreamBridge or a function's return value, and we keep every destination and group name unchanged so Kafka offsets and RabbitMQ queues are reused. We publish a migration guide, migrate one pilot service first, schedule the rest by upgrade urgency, and test each one against real brokers before production.
Background to this question
The annotation model of Spring Cloud Stream was removed in version 4, which is the line that goes with Spring Boot 3. Services still using it are stuck on old Spring Boot versions, which soon means no security fixes. With thirty services owned by different teams, the risk is less in any single change and more in doing it thirty times without losing messages or reprocessing them. In this answer, we will recap the two models, build the inventory, map the old constructs to the new ones, see why keeping destinations and groups matters, and plan the rollout across teams.
1A Quick Recap of the Two Models
In the annotation model, a service declared channels through an interface such as Sink or Processor, enabled them with @EnableBinding, and handled messages with @StreamListener methods. Outputs were MessageChannel objects that code sent to, or @SendTo on the handler. Bindings were named after the channels, input and output.
In the functional model, a service declares Supplier, Function and Consumer beans, and the framework creates bindings named after the beans, such as handleOrder-in-0. Imperative sends that do not come from an input message use StreamBridge. Spring Cloud Stream 3.x supports both models side by side, which is what makes a gradual migration possible: we migrate on 3.x, then upgrade.
2Inventory the Services
For each service we record its bindings, their destinations and groups, partitioning settings, and the features that need special care. The most common are @StreamListener conditions (a SpEL expression that dispatches messages to different methods by header), error channels and @ServiceActivator error handlers, custom MessageConverter beans, and polled consumers. A search for @StreamListener, @EnableBinding, @Output and @Input across the repositories, plus each service's binding properties, gives most of this in an afternoon.
| Annotation model | Functional model |
|---|---|
@EnableBinding(Sink.class) + @StreamListener | @Bean Consumer<T> |
@StreamListener + @SendTo (Processor) | @Bean Function<In, Out> |
MessageChannel output, channel.send(...) | StreamBridge.send("name-out-0", payload) |
@StreamListener(condition = "...") | routing function or a switch inside one Consumer |
bindings.input.destination / group | bindings.handleOrder-in-0.destination / group, same values |
| error channel handler | error channel or binder DLQ, check naming in your version |
The inventory also records each service's current Spring Boot version and how urgent its upgrade is, for example because it is on a version with no more security patches. That becomes the schedule.
3Map Each Listener, Keeping Names
The code change itself is small. The essential rule is that the destination and group values stay exactly the same, even though the binding name changes.
- Migrate code on Spring Cloud Stream 3.xfunctional beans,
StreamBridge - Keep destinations and groupssame offsets and queues
- Test against real brokersTestcontainers Kafka or RabbitMQ
- Deploy and comparelag, throughput, DLQ, errors
- Upgrade Spring Boot and Stream 4.xa separate, later change
5 steps in order. Play them, or step through them one at a time.
Why does it matter so much? On Kafka, the group name is the consumer group, and Kafka stores the committed offsets under it. Keep billing, and the migrated service continues exactly where the old one stopped. Change it, and the new group either starts from the latest offset and skips messages, or from the earliest and reprocesses the whole topic. On RabbitMQ, the binder names the durable queue after destination and group, orders.billing, so the same values reuse the existing queue and its waiting messages; different values create a new, empty queue.
4Replace Output Sends and Special Features
Code that sent to an output channel becomes either the return value of a Function, when the output is a direct result of an input, or a StreamBridge call, when it starts elsewhere, such as in a REST controller. Conditions on @StreamListener, which dispatched different message types to different methods, become either a single Consumer that switches on a header, or Spring Cloud Function's routing function with a routing expression. Custom converters usually keep working as MessageConverter beans. Error handlers need checking in our version, since dead-letter queues configured on the binder are usually the cleaner replacement.
5Roll Out Across Teams
We would not ask thirty teams to work it out separately. A small group writes a migration guide with before-and-after examples for each construct in the table, including the properties, and migrates one pilot service end to end, ideally one that uses several features. The pilot finds the surprises, and the guide is corrected before the other teams start.
Then we schedule by urgency: services on unsupported Boot versions or with security exposure first, simple ones early to build confidence, the most complex last. Each team tests against real brokers in its pipeline, using Testcontainers for Kafka or RabbitMQ, because the test binder cannot show offset or queue behaviour. In production we deploy the migrated version while watching consumer lag, throughput, error rates and the DLQ, and keep the previous build ready for rollback; with the same group, rolling back is safe because offsets and queues are shared. Only after the code is on the functional model do we upgrade Spring Boot and Spring Cloud Stream, as a separate change, so we never debug two changes at once.
6Follow-up questions
Can we do the migration and the Spring Boot 3 upgrade in one step?
We can, but we should not. The Boot 3 upgrade brings Jakarta namespaces, Java 17 as a minimum and many dependency changes. Migrating the messaging model on Spring Cloud Stream 3.x first, where both models work, means each change is tested separately and a problem points at one cause.
What if two old listeners consumed the same destination with conditions?
In the annotation model, conditions let one binding dispatch to several methods. In the functional model, one binding has one function, so we use a single Consumer that switches on a type header, or the routing function that chooses a target function by expression. Splitting into two bindings with different groups would change who receives what.
How do we know no messages were lost or reprocessed?
We compare the consumer group's committed offsets before and after the deployment on Kafka, or the queue depth on RabbitMQ, and watch the business counts for the period, such as invoices created per order received. A consumer that is idempotent protects against the duplicates a rollback might cause.
7Conclusion
In this answer, we planned the migration of thirty services from the removed annotation model. We inventoried bindings and special features, mapped each @StreamListener to a Consumer or Function bean and each output send to StreamBridge, kept every destination and group unchanged so offsets and queues are reused, piloted one service with a migration guide, scheduled the rest by upgrade urgency, and tested against real brokers before production and before the separate Boot upgrade.
Open with
I'd start with an inventory across the thirty services: every binding with its destination and group, plus the features that need care, like StreamListener conditions, error channel handlers, custom converters and polled consumers, and each service's Boot version so I know how urgent it is.
Then, if they want more
The code mapping is mechanical. A StreamListener on a Sink becomes a Consumer bean, a Processor with SendTo becomes a Function, and sends to an output MessageChannel become StreamBridge calls or function return values. Conditions become a single consumer that switches on a header, or the routing function.
The rule I'd stress is to keep destinations and groups exactly the same, even though the binding names change from input to something like handleOrder-in-0.
On Kafka the group holds the committed offsets, so a new group name would either skip or reprocess messages; on RabbitMQ the queue is named destination dot group, so the same values reuse the existing queue and its backlog. I'd do the migration on Spring Cloud Stream 3.x, which supports both models, and upgrade Boot separately afterwards.
For the rollout, a small group writes a guide with examples and migrates a pilot service first, then teams follow in order of urgency. Each service is tested against real brokers with Testcontainers, and in production we watch lag, errors and the DLQ, with rollback ready.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 17, Spring Boot 3
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Cloud Stream reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Thirty services still use the Spring Cloud Stream annotation model (@EnableBinding...": https://scrivio-interview-library.netlify.app/spring-boot/spring-cloud-stream/514a514d83/