Search in sources :

Example 1 with KafkaSender

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()));
    }
}
Also used : CustomSubject(com.topcom.cms.yuqing.domain.CustomSubject) KafkaSender(com.topcom.cms.yuqing.task.kafka.KafkaSender) BaseKafkaSender(com.topcom.cms.yuqing.task.kafka.BaseKafkaSender) Date(java.util.Date) Test(org.junit.Test)

Aggregations

CustomSubject (com.topcom.cms.yuqing.domain.CustomSubject)1 BaseKafkaSender (com.topcom.cms.yuqing.task.kafka.BaseKafkaSender)1 KafkaSender (com.topcom.cms.yuqing.task.kafka.KafkaSender)1 Date (java.util.Date)1 Test (org.junit.Test)1