Package kafka.producer

Examples of kafka.producer.SimpleProducer


    Props nodesProps = KafkaETLUtils.readProps(nodePath);
    _producers = new ArrayList<SimpleProducer>();
    for (String key : nodesProps.stringPropertyNames()) {
      URI uri = nodesProps.getUri(key);
      System.out.println("server uri:" + uri.toString());
      _producers.add(new SimpleProducer(uri.getHost(), uri.getPort(),
          TCP_BUFFER_SIZE, CONNECT_TIMEOUT, RECONNECT_INTERVAL));
    }
  }
View Full Code Here


  }

  public void run() throws IOException, URISyntaxException {

    int producerId = RANDOM.nextInt() % _producers.size();
    SimpleProducer producer = _producers.get(producerId);

    List<Message> list = new ArrayList<Message>();
    for (int i = 0; i < _count; i++) {
      Long timestamp = RANDOM.nextLong();
      if (timestamp < 0) timestamp = -timestamp;
      byte[] bytes = timestamp.toString().getBytes("UTF8");
      Message message = new Message(bytes);
      list.add(message);
    }
    // send events
    System.out.println(" send " + list.size() + " " + _topic
        + " count events to " + producerId);
    producer.send(_topic, new ByteBufferMessageSet(list));

    // close all producers
    for (SimpleProducer p : _producers) {
      p.close();
    }
View Full Code Here

  public Producer(String topic, String kafkaServerURL, int kafkaServerPort,
                  int kafkaProducerBufferSize, int connectionTimeOut, int reconnectInterval,
                  int messageSize, String name, int batchSize, int numParts)
  {
    producer = new SimpleProducer(kafkaServerURL,
                                 kafkaServerPort,
                                 kafkaProducerBufferSize,
                                 connectionTimeOut,
                                 reconnectInterval);
    this.topic = topic;
View Full Code Here

  private final SimpleProducer producer;
  private final String topic;
 
  public Producer(String topic)
  {
    producer = new SimpleProducer(KafkaProperties.kafkaServerURL,
                                  KafkaProperties.kafkaServerPort,
                                  KafkaProperties.kafkaProducerBufferSize,
                                  KafkaProperties.connectionTimeOut,
                                  KafkaProperties.reconnectInterval);
    this.topic = topic;
View Full Code Here

TOP

Related Classes of kafka.producer.SimpleProducer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.