Skip to content

Fix scheduler for calling chat models streaming - #6814

Open
EgbertW wants to merge 1 commit into
spring-projects:mainfrom
EgbertW:fix-model-scheduler
Open

Fix scheduler for calling chat models streaming#6814
EgbertW wants to merge 1 commit into
spring-projects:mainfrom
EgbertW:fix-model-scheduler

Conversation

@EgbertW

@EgbertW EgbertW commented Aug 18, 2026

Copy link
Copy Markdown

Replace publishOn with subscribeOn for calling a chat model in the streaming flow.

publishOn affects the flow downstream of where it is defined, which doesn't make that much sense in this context because it's forwarding from I/O call, not producing an I/O call.

At least for the Google GenAI chat models, OkHttp is used in a blocking call. With publishOn this ends up blocking the original thread (e.g. a Spring Boot worker thread) and only AFTER the I/O call switching to the boundedElastic pool. It makes a lot more sense to run the OkHttp blocking call on the boundedElastic scheduler instead to free up the worker thread.

If needed, you could release that afterwards but there's not a lot of value in that.

@EgbertW
EgbertW force-pushed the fix-model-scheduler branch 2 times, most recently from 31df7c8 to b6091c5 Compare August 18, 2026 13:37
Signed-off-by: Egbert van der Wal <ewal@pointpro.nl>
@EgbertW
EgbertW force-pushed the fix-model-scheduler branch from b6091c5 to f87fcb9 Compare August 18, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants