selectKey assigns a new key to each input event so related records can reach matching Kafka Streams tasks for a join. section 8.3.6
Use selectKey when stream records carry different keys from the attribute required for correlation:
- Change a Payment event's key from paymentId to its orderId attribute. section 8.3.6
- Let Kafka Streams create an intermediate topic with the new keys, aligning records for downstream processing. section 8.3.6
Orders and Payments
An Orders topic uses orderId while a Payments topic uses paymentId. Applying selectKey to Payments with orderId makes both streams joinable, provided their partitioning is aligned. section 8.3.6
