use of com.topcom.cms.yuqing.task.kafka.KafkaSender in project topcom-cloud by 545314690.
the class KafkaTest method sendSubject.
@Test
public void sendSubject() {
KafkaSender kafkaSender = new KafkaSender();
kafkaSender.setProps(props);
CustomSubject subject = new CustomSubject();
subject.setMustWord("江苏@幼儿园@爆炸");
subject.setName("江苏幼儿园爆炸");
subject.setShouldWord("爆炸");
subject.setStartDate(DateUtils.addDays(new Date(), -5));
subject.setEndDate(DateUtils.addDays(new Date(), 30));
for (int i = 0; i < 1000; i++) {
if (i % 2 == 0)
subject.setDeleted(true);
else
subject.setDeleted(false);
kafkaSender.getProducer().send(new ProducerRecord<String, String>(SUBJECT_TOPIC, net.sf.json.JSONObject.fromObject(subject).toString()));
}
}
Aggregations