I am trying access an already created object in a microservice from another microservice in vain.
The complete description of the problem is as follows –
framework – spring,
build tool – gradle
Microservice A :
An object of TypeABC is created (Using singleton design pattern) using Create() method. I get the same object whenever I call getInstanceOfABC().
What I want to achieve in Microservice B :
When I call getInstanceOfABC(), I want the same instance of TypeABC which was earlier created in Microservice A.
Here’s what I tried so far
- Tried using application context to load the bean. But Everytime I do it, the spring creates new set of beans and does not return a existing bean.
- Used singleton design pattern, it works well in the same microservice but fails while trying from another microservice.
But these methods doesn’t seem to work. Please suggest a way to achieve this.
Thanks