WIP
Jira item: - CPS-459Getting issue details... STATUS
Introduction
CPS system is providing a Json Schema for that defines the format of events used to notify about CPS data updates. See CPS-191: Core and Temporal Integration Design for more details.
When CPS system is going to evolve, depending on the evolution made, it might happen that the initially defined schema for Data Updated Event has also to be changed. If such changes are not planned properly they can be complex and risky to implement in a running production system. Event schema changes has to be implemented in both producer and consumers systems and has to be flexible enough so that all components does not have to be updated at the exact same time to respect key micro services design principles: loosely coupled and independently deployable. Then, the system is expected to support a transition period when some components are running with an event schema updated while some other are not.
The purpose of this spike is to propose a strategy to ensure that CPS Data Updated event schema will be able to evolve with future requirements to come.
Compatibility Types
CPS supports one of the 3 following compatibility types between 2 consecutive event schema versions:
Forward Compatibility
Forward compatibility type allows events produced by the new schema to be consumed by the previous schema.
This type has the following constraints:
- Only changes allowed in the new schema are:
- Add fields
- Delete optional fields
- Producer as to be upgraded first
Backward Compatibility
Backward compatibility type allows events produced by the previous schema to be consumed by the new schema.
This type has the following constraints:
- Only changes allowed in the new schema are:
- Delete fields
- Add optional fields
- All consumers as to be upgraded first
Full Compatibility
Full compatibility type implies both Forward and Backward compatibility. It means that events produced by the new schema can be consumed by the previous schema and also that events produced by the previous schema can be read by the new schema.
This type has the following constraints:
- Only changes allowed in the new schema are:
- Add optional fields
- Delete optional fields
This type does not have any constraint on the order to complete components upgrades. It gives more flexibility as producer and consumers can be upgraded in any order.
See https://docs.confluent.io/platform/current/schema-registry/avro.html for more details about these compatibility types.
Proposed Solution for Istanbul
Limitations
As described in Complete solution using current event schema implementation, the requirement to support all types of evolution can be fulfilled, but it introduces an additional complexity on the application design because of lacking a common type that all events are implementing to be able to give more flexibility to handle these classes. Then, we need to consider if we should manually write event classes code instead of leveraging "Json Schema 2 Pojo" plugin to have these classes automatically generated. This can be looked during next release.
Meanwhile, for Istanbul, we are proposing to make minimal changes to support a basic Forward Compatibility change in Jakarta without implementing a complete solution supporting all compatibility types and deployment options yet.
This means that for next release after Istanbul the deployment order will have to be :
- Deploy CPS Core new release (events form new schema are produced and still consumed as events from previous schema).
- Deploy CPS Temporal new release (event from new schema are produced and now consumed as events from new schema).
Changes
Reference note lo look at Jackson classes hierarchy for event classes: https://www.baeldung.com/jackson-inheritance