WebFlux call `bodyToMono()` twice throws `IllegalStateException`

二次信任 提交于 2019-12-23 04:41:54

问题


I'm currently working on creating a logging ExchangeFilterFunction that can be used for any WebFlux WebClient to log both requests and responses. The issue I am running into is that when I attempt to log the body of the response I get the following:

java.lang.IllegalStateException: Only one connection receive subscriber allowed.

I understand why it's happening as Spring only allows one subscriber to the stream. My question is how can I obtain the body in two decoupled places? I have tried using the cache operator in Reactor but that does not seem to help even though I thought that was exactly what it's used for.

来源:https://stackoverflow.com/questions/56238895/webflux-call-bodytomono-twice-throws-illegalstateexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!