问题
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