by BehindJava

What is a CDC or Consumer Defined Contract in Microservice

Home » microservices » What is a CDC or Consumer Defined Contract in Microservice

This is a quick tutorial on Consumer Defined Contract in Microservice architecture.

Consumer Defined Contract

  • Consumer Defined Contracts is a pattern defined by Martin Fowler.
  • In Consumer Defined Contracts, each consumer captures their expectations of the provider in a separate contract.All of these contracts are shared with the provider so they gain insight into the obligations they must fulfil for each individual client.
  • Implementations:

  • CDC is a kind of test to ensure that constant changes in the microservices does not break the dependent microservices.
  • We have a defined Provider API and a Consumer API to avoid ambiguity.
  • The consumer has to write the test for that contract between the consumer and provider. In the pre-staging environment of deployment, consumer will run the tests. If the test fails to pass the contract then deployment is terminated.
  • The provider also runs the consumer test on its side before the deployment and makes sure that its changes wont effect the consumers to whom it is providing the services.