コード例 #1
0
  @Test
  public void testThriftKafkaProducer() {
    KafkaProducer<String, Domainsync> kafkaProducer = KafkaProducerFactory.getThriftKafkaProducer();

    for (int i = 0; i < 10; i++) {
      Domainsync domainsync = new Domainsync();
      domainsync.setDomain("sohusohu");
      domainsync.setPassport("babyduncan" + i + "@qq.com");
      domainsync.setSid(100000);
      domainsync.setType(0);
      kafkaProducer.send("testthrift", domainsync);
    }
  }
コード例 #2
0
  @Test
  public void testGetKafkaProducer() throws Exception {

    KafkaProducer<String, String> kafkaProducer = KafkaProducerFactory.getKafkaProducer();

    for (int i = 0; i < 10; i++) {

      String s =
          "{\"domain\":\"sohubabyduncan"
              + i
              + "\",\"type\":\"0\",\"passport\":\"[email protected]\",\"sid\":\"2000004436\"}";
      System.out.println(s);
      kafkaProducer.send("domainsync", "zghbbdc" + System.currentTimeMillis());
    }
  }