I was using a single instance bean of chatClient and starting with the second call to the stream method i got an exception "java.lang.IllegalStateException: Unicast Sinks.Many allows only a single Subscriber". I am not sure if this is a bug or intended behaviour. I'm new to Flux, but i think this happens because the Flux is always created from the same Sink instance in AbstractBedrockApi.internalInvocationStream() I'm proxying controller calls sp i've added web request scope @Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS) to the BedrockAnthropicChatClient bean, that fixed my use case.
Comment From: tzolov
Hi @timograw , thanks for raising this. It looks like a bug. Will try to reproduce it.
Comment From: tzolov
@timograw, I can reproduce the issue and it is affecting all Bedrock streaming models.
It looks like the Sinks.Many<SO> eventSink
must be created per each stream method request rather than per class instance.
Fix is coming.
Comment From: tzolov
@timograw , i've merged a fix (1.0.0-SNAPSHOT). Please give it a try. I'm still preform additional review of this an other related implementation to verify i'm not stalling/leaking resources.