马老师分布式定时任务调度解析
int partitionNum = Integer.parseInt((String) key);**
** return Math.abs(Integer.parseInt((String) key) % numPartitions);**
** }catch(Exception e) {**
** return Math.abs(key.hashCode() % numPartitions);**
** }**
** }**
}
** 如果将上例中的class作为partition.class,并通过如下代码发送20条消息(key分别为0,1,2,3)至topic2(包含4个partition)。**
public void sendMessage()throws InterruptedException{