Package org.apache.twill.kafka.client

Examples of org.apache.twill.kafka.client.FetchedMessage


    }

    @Override
    public FetchedMessage next() {
      recordLastOffset();
      FetchedMessage message = delegate.next();
      lastTopicPartition = message.getTopicPartition();
      lastOffset = message.getNextOffset();

      messageCount.incrementAndGet();
      return message;
    }
View Full Code Here


  @Override
  public void onReceived(Iterator<FetchedMessage> messages) {
    int count = 0;
    while (messages.hasNext()) {
      FetchedMessage message = messages.next();
      try {
        GenericRecord genericRecord = serializer.toGenericRecord(message.getPayload());
        ILoggingEvent event = serializer.fromGenericRecord(genericRecord);
        LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(event.getMDCPropertyMap());

        synchronized (messageTable) {
          long key = event.getTimeStamp() / eventBucketIntervalMs;
          List<KafkaLogEvent> msgList = messageTable.get(key, loggingContext.getLogPathFragment());
          if (msgList == null) {
            msgList = Lists.newArrayList();
            messageTable.put(key, loggingContext.getLogPathFragment(), msgList);
          }
          msgList.add(new KafkaLogEvent(genericRecord, event, loggingContext,
                                        message.getTopicPartition().getPartition(), message.getNextOffset()));
        }
      } catch (Throwable e) {
        LOG.warn("Exception while processing message with nextOffset {}. Skipping it.", message.getNextOffset(), e);
      }
      ++count;
    }
    LOG.debug("Got {} messages from kafka", count);
  }
View Full Code Here

TOP

Related Classes of org.apache.twill.kafka.client.FetchedMessage

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.