By default is it necessary to specify the min.compaction.lag.ms or 0 means that compaction runs on every new message?
I did create a new topic with the property compact but in ksql when I print for topic messages I see them all, there is no compaction.
@Bean
public NewTopic topicPatientLocation() {
return TopicBuilder.name("adt.patient.location").partitions(1).compact().replicas(1).build();
}
The output from the topic is:
ksql> print 'adt.patient.location' from BEGINNING;
Key format: KAFKA_STRING
Value format: AVRO or KAFKA_STRING
rowtime: 2021/04/20 12:43:12.821 Z, key: 1-3, value: {"patientId": 1, "episodeOfCareId": 2, "wardId": 3, "roomId": 11, "bedId": 2, "status": "ACTIVE", "date": null}
rowtime: 2021/04/20 12:43:41.005 Z, key: 1-3, value: {"patientId": 1, "episodeOfCareId": 2, "wardId": 3, "roomId": 0, "bedId": 0, "status": "PAST", "date": null}
rowtime: 2021/04/20 12:45:18.827 Z, key: 1-3, value: {"patientId": 1, "episodeOfCareId": 2, "wardId": 3, "roomId": 10, "bedId": 0, "status": "ACTIVE", "date": null}
rowtime: 2021/04/20 12:46:14.534 Z, key: 2-3, value: {"patientId": 2, "episodeOfCareId": 2, "wardId": 3, "roomId": 11, "bedId": 4, "status": "ACTIVE", "date": null}
rowtime: 2021/04/20 12:46:26.306 Z, key: 2-3, value: {"patientId": 2, "episodeOfCareId": 2, "wardId": 3, "roomId": 11, "bedId": 2, "status": "ACTIVE", "date": null}
I was expecting to see only two messages, the latest by the two corresponding message keys 1-3 and 2-3.
Topic configuration
Topic: adt.patient.location PartitionCount: 1 ReplicationFactor: 1 Configs: cleanup.policy=compact
Topic: adt.patient.location Partition: 0 Leader: 1 Replicas: 1 Isr: 1