use of org.apache.apex.malhar.kafka.KafkaSinglePortInputOperator in project apex-malhar by apache.
the class StreamFactory method fromKafka09.
/**
* Create stream of byte array messages from kafka 0.9
* @param brokers
* @param topic
* @param opts
* @return
*/
public static ApexStream<byte[]> fromKafka09(String brokers, String topic, Option... opts) {
KafkaSinglePortInputOperator kafkaInput = new KafkaSinglePortInputOperator();
kafkaInput.setClusters(brokers);
kafkaInput.setTopics(topic);
ApexStreamImpl<String> newStream = new ApexStreamImpl<>();
return newStream.addOperator(kafkaInput, null, kafkaInput.outputPort, opts);
}
use of org.apache.apex.malhar.kafka.KafkaSinglePortInputOperator in project apex-malhar by apache.
the class StreamFactory method fromKafka09.
/**
* Create stream of byte array messages from kafka 0.9 with more partition options
*/
public static ApexStream<byte[]> fromKafka09(String brokers, String topic, PartitionStrategy strategy, int partitionNumber, Option... opts) {
KafkaSinglePortInputOperator kafkaInput = new KafkaSinglePortInputOperator();
kafkaInput.setClusters(brokers);
kafkaInput.setTopics(topic);
kafkaInput.setStrategy(strategy.name());
kafkaInput.setInitialPartitionCount(partitionNumber);
ApexStreamImpl<String> newStream = new ApexStreamImpl<>();
return newStream.addOperator(kafkaInput, null, kafkaInput.outputPort, opts);
}
Aggregations