This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
Cyclic dependency during bean initialization #248
Unanswered
BoceaVladian
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have an issue that I am not sure how to fix with Alibaba Rsocket Broker v1.1.6 .
It looks as if injecting an Rsocket client created through the RSocketRemoteServiceBuilder in a service created with @RSocketService is not working. This means that the server cannot call other microservices for data using Rsocket clients.
Code example adapted from the Alibaba Rsocket Broker spring boot example:
Service:
Clients:
When injecting the AccountService client into the Rx3UserServiceImpl service I get a cyclic dependency error as the Upstream manager cannot be injected into the AccountService due to bean is under creation.
The issues seems to come from the fact that the RSocketAutoConfiguration class has an init method on the upstreamManager bean as follows:
The SmartLifecycleUpstreamManagerImpl's init method reaches the UpstreamCluster#init method which at line 138calls
The LoadBalancedRSocket does this at line 102:
The exposedServices().get() method queries the application context for the @RSocketService annotated beans which have as dependency the AccountService with the upstreamManager as the dependency resulting in a cyclic dependency failure.
Am I missing something or perhaps I misconfigured something? Did anybody else run into the same issue?
EDIT: I know this works if i lazily inject the dependency in the Rx3UserServiceImpl to fix the cyclic dependency, however this is more a quick hacky solution than a proper way of doing things.
Beta Was this translation helpful? Give feedback.
All reactions