private OffsetResponse sendOffsetRequest(Integer brokerId, TopicVO topic, PartitionOffsetRequestInfo requestInfo, List<TopicPartitionVO> brokerPartitions) { final OffsetRequest offsetRequest = new OffsetRequest( brokerPartitions.stream() .collect(Collectors.toMap( partition -> new TopicAndPartition(topic.getName(), partition.getId()), partition -> requestInfo)), (short) 0, clientId()); LOG.debug("Sending offset request: {}", offsetRequest); return retryTemplate.execute( context -> brokerChannel(brokerId) .execute(channel -> { channel.send(offsetRequest.underlying()); final kafka.api.OffsetResponse underlyingResponse = kafka.api.OffsetResponse.readFrom(channel.receive().buffer()); LOG.debug("Received offset response: {}", underlyingResponse); return new OffsetResponse(underlyingResponse); })); }