Sobes.tech
Middle+

What is the difference between consumer-driven contracts and producer-driven contracts?

sobes.tech AI

Answer from AI

In Consumer Driven Contracts (CDC), the consumer defines the data format it expects from the service and creates a contract (expectation specification). The provider uses this contract to verify that its service meets the consumer's requirements.

In Producer Driven Contracts (PDC), the service provider defines the data format provided by its service and creates a contract. The consumer then uses this contract to ensure it can correctly work with the data provided by the provider.

The key difference is who initiates the creation and management of the contract and, accordingly, who bears the main responsibility for keeping it up-to-date according to their needs/capabilities.

Comparison:

Aspect Consumer Driven Contracts (CDC) Producer Driven Contracts (PDC)
Initiator Consumer Producer
Responsibility for relevance Consumer (for its needs) and Producer (for compliance) Producer
Main goal Ensure that the service meets the consumer's needs Ensure that consumers can use the service
Risk shift Reduces the risk of failure for the consumer when the service changes Reduces the risk of failure for the producer when the consumer changes

CDC is more suitable for microservice architecture or when one producer has many diverse consumers with different requirements. PDC is convenient when the producer is dominant or when the service is unified and used uniformly by many consumers.

What is the difference between consumer-driven… - sobes.tech