Package kafka.producer

Examples of kafka.producer.KeyedMessage


        for (TridentTuple tuple : tuples) {
            try {
                topic = topicSelector.getTopic(tuple);

                if(topic != null) {
                    producer.send(new KeyedMessage(topic, mapper.getKeyFromTuple(tuple),
                            mapper.getMessageFromTuple(tuple)));
                } else {
                    LOG.warn("skipping key = " + mapper.getKeyFromTuple(tuple) + ", topic selector returned null.");
                }
            } catch (Exception ex) {
View Full Code Here


          int size = ((ByteBuffer)payload_07).remaining();
          byte[] bytes = new byte[size];
          ((ByteBuffer)payload_07).get(bytes);
          if(logger.isDebugEnabled())
            logger.debug("Migration thread " + threadId + " sending message of size " + bytes.length + " to topic "+ topic);
          KeyedMessage<byte[], byte[]> producerData = new KeyedMessage((String)topic, null, bytes);
          producerDataChannel.sendRequest(producerData);
        }
        logger.info("Migration thread " + threadName + " finished running");
      } catch (InvocationTargetException t){
        logger.fatal("Migration thread failure due to root cause ", t.getCause());
View Full Code Here

    props.put("request.timeout.ms", "30000");
    log.debug("Broker list: " + brokerList);
    Producer producer = new Producer(new ProducerConfig(props));
    try {
      for (byte[] message : monitorSet) {
        KeyedMessage keyedMessage = new KeyedMessage(
            "TrackingMonitoringEvent", message);
        producer.send(keyedMessage);
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

    }

    private void send(Producer producer,String header, String topic, String message) {
        final Long time = TimeUnit.MILLISECONDS.toSeconds(clock.time() - startTime);
        try {
            producer.send(new KeyedMessage(topic, format("%s\n%d,%s", header, time, message).getBytes("UTF-8")));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

TOP

Related Classes of kafka.producer.KeyedMessage

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.