JavaDocs부터 시작하자! 당신이 DefaultPartitioner
에 의존 할 것인지
/**
* Send the data to the default topic with the provided key and no partition.
* @param key the key.
* @param data The data.
* @return a Future for the {@link SendResult}.
*/
ListenableFuture<SendResult<K, V>> sendDefault(K key, V data);
/**
* The default partitioning strategy:
* <ul>
* <li>If a partition is specified in the record, use it
* <li>If no partition is specified but a key is present choose a partition based on a hash of the key
* <li>If no partition or key is present choose a partition in a round-robin fashion
*/
public class DefaultPartitioner implements Partitioner {
그래서, 당신이 필요로하는 모든 레코드에 대한
key
입니다. 따라서 해당 특정
KafkaTemplate
방법을 사용하십시오.
kafkaTemplate.sendDefault(job.getId(),job);
감사합니다! 그게 효과가 있었어. 내가 파티션을 확인하기 위해 사용했던 카프카 도구에 문제가 있었어. 나는 카프카 콘솔 소비자를 대신 사용 했었고 예상되는 파티션에서 메시지를 볼 수있었습니다. –
좋아요! 이제 이것을 생각해보십시오 : http://stackoverflow.com/help/someone-answers –