@MessagePattern maps to a Kafka topic name. Use @Ctx() to inject a KafkaContext which exposes getTopic(), getPartition(), and getMessage() containing the offset and headers. Publish messages with a key to determine partition assignment and include headers for cross-cutting concerns like correlation IDs.
Message key determines which partition receives the message — same key always goes to the same partition.
All messages with the same key are ordered within their partition — critical for event sourcing.
Without a key, Kafka round-robins across partitions — no ordering guarantee.
Offset identifies the message position within a partition — use it for manual offset commits.
Headers are available via ctx.getMessage().headers — use for correlation IDs and trace context propagation.