Package kafka.producer

Examples of kafka.producer.ProducerConfig


  @Test
  public void testNoParsingAsFlumeAgent() throws Exception {
    final KafkaChannel channel = startChannel(false);
    Producer<String, byte[]> producer = new Producer<String, byte[]>(
      new ProducerConfig(channel.getKafkaConf()));
    List<KeyedMessage<String, byte[]>> original = Lists.newArrayList();
    for (int i = 0; i < 50; i++) {
      KeyedMessage<String, byte[]> data = new KeyedMessage<String,
        byte[]>(topic, null, RandomStringUtils.randomAlphabetic(6),
        String.valueOf(i).getBytes());
View Full Code Here


    props.put("metadata.broker.list","127.0.0.1:" +
            kafkaServer.serverConfig().port());
    props.put("serializer.class","kafka.serializer.StringEncoder");
    props.put("request.required.acks", "1");

    ProducerConfig config = new ProducerConfig(props);

    producer = new Producer<String,String>(config);

  }
View Full Code Here

  }

  @Override
  public synchronized void start() {
    // instantiate the producer
    ProducerConfig config = new ProducerConfig(kafkaProps);
    producer = new Producer<String, byte[]>(config);
    super.start();
  }
View Full Code Here

  @Override
  public void start() {
    try {
      LOGGER.info("Starting Kafka Channel: " + getName());
      producer = new Producer<String, byte[]>(new ProducerConfig(kafkaConf));
      // We always have just one topic being read by one thread
      LOGGER.info("Topic = " + topic.get());
      topicCountMap.put(topic.get(), 1);
      super.start();
    } catch (Exception e) {
View Full Code Here

        props.put("client.id", "graylog2-radio-" + serverStatus.getNodeId().toString());
        props.put("producer.type", configuration.getKafkaProducerType());
        props.put("queue.buffering.max.ms", String.valueOf(configuration.getKafkaBatchMaxWaitMs()));
        props.put("batch.num.messages", String.valueOf(configuration.getKafkaBatchSize()));

        ProducerConfig config = new ProducerConfig(props);
        producer = new Producer<>(config);

        incomingMessages = metricRegistry.meter(name(KafkaProducer.class, "incomingMessages"));
        rejectedMessages = metricRegistry.meter(name(KafkaProducer.class, "rejectedMessages"));
        processTime = metricRegistry.timer(name(KafkaProducer.class, "processTime"));
View Full Code Here

  {
    props.put("serializer.class", "kafka.serializer.StringEncoder");
    props.put("zk.connect", "localhost:2181");
    // Use random partitioner. Don't need the key type. Just set it to Integer.
    // The message is of type String.
    producer = new kafka.javaapi.producer.Producer<Integer, String>(new ProducerConfig(props));
    this.topic = topic;
    this.fileName = fileName;
   
  }
View Full Code Here

        Validate.notNull(mapper, "mapper can not be null");
        Validate.notNull(topicSelector, "topicSelector can not be null");
        Map configMap = (Map) stormConf.get(KAFKA_BROKER_PROPERTIES);
        Properties properties = new Properties();
        properties.putAll(configMap);
        ProducerConfig config = new ProducerConfig(properties);
        producer = new Producer(config);
    }
View Full Code Here

        }

        Map configMap = (Map) stormConf.get(KAFKA_BROKER_PROPERTIES);
        Properties properties = new Properties();
        properties.putAll(configMap);
        ProducerConfig config = new ProducerConfig(properties);
        producer = new Producer<K, V>(config);
        this.collector = collector;
    }
View Full Code Here

    private void createTopicAndSendMessage(String key, String value) {
        Properties p = new Properties();
        p.setProperty("metadata.broker.list", broker.getBrokerConnectionString());
        p.setProperty("serializer.class", "kafka.serializer.StringEncoder");
        ProducerConfig producerConfig = new ProducerConfig(p);
        Producer<String, String> producer = new Producer<String, String>(producerConfig);
        producer.send(new KeyedMessage<String, String>(config.topic, key, value));
    }
View Full Code Here

    }

    @Override
    protected void doStart() throws Exception {
        Properties props = getProps();
        ProducerConfig config = new ProducerConfig(props);
        producer = new Producer<String, String>(config);
    }
View Full Code Here

TOP

Related Classes of kafka.producer.ProducerConfig

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.