user310291
user310291

Reputation: 38228

Dependency Injection in Distributed System

How do you implement DI in Distributed System since you cannot embed a whole DI framework with each distibuted component.

Upvotes: 1

Views: 519

Answers (3)

Mark Seemann
Mark Seemann

Reputation: 233347

In a distributed system each Autonomous Component is an individual application in itself, so should have each own Composition Root at which you wire components. If you use a DI Container, you should use the Register Resolve Release pattern.

Since each component is an application in itself, they don't even have to use the same container (or even the same platform).

Upvotes: 5

Joseph Ottinger
Joseph Ottinger

Reputation: 4951

Well, you can distribute the DI platform with each component, if you like. Some platforms integrate DI so you can more or less do it as a feature of the platform.

However, the better way to think of it is to use the platform instead of relying on injection. Distribute method calls to other distributed components, and you gain scalability (although you'll possibly lose performance) and simplicity in your design.

Upvotes: 1

mP.
mP.

Reputation: 18266

Well if the DI framework is not present then you cant very well refer to it directly/indirectly if its not present... If you wish to use DI in your distributed component it must be localy available as remote DI does not make sense as services themselves typically are not serializable because the concept does not make sense.

Upvotes: 0

Related Questions