ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey <j...@list.ru>
Subject Ignite and Kafka issue
Date Fri, 20 May 2016 12:20:27 GMT
Hello!
I am trying to execute simple example with Ignite and KafkaConsumer.
Unfortunately I can't get any messages using KafkaConsumer and I can't find
where is a problem. Message is always null although consumer started in
command line shows all messages that was sent by Producer in my example. 
Could you please take a look at my example?

public class KafkaTest2 {
    public static void main(String[] args) throws IgniteException {
        try (Ignite ignite =
Ignition.start("examples/config/example-ignite.xml")) {
            Properties prodProps = new Properties();
            prodProps.put("key.serializer",
                   
"org.apache.kafka.common.serialization.StringSerializer");
            prodProps.put("value.serializer",
                   
"org.apache.kafka.common.serialization.StringSerializer");

            prodProps.put("bootstrap.servers", "localhost:9092");

            try (Producer<String, String> producer = new
KafkaProducer<>(prodProps)) {
                ProducerRecord<String, String> data1 = new
ProducerRecord<String, String>(
                        "test", "key1", "test-msg1");
                producer.send(data1);
            }

            Properties consumerProps = (Properties) prodProps.clone();
            consumerProps.put("key.deserializer",
"org.apache.kafka.common.serialization.StringDeserializer");
            consumerProps.put("value.deserializer",
"org.apache.kafka.common.serialization.StringDeserializer");
            consumerProps.put("group.id", "testId");
            consumerProps.put("partition.assignment.strategy",
"roundrobin");

            try (Consumer<String, String> consumer = new
KafkaConsumer<>(consumerProps)) {
                consumer.subscribe("test");

                Map<String, ConsumerRecords&lt;String, String>> msg  = null;
                while (msg  == null) {
                    msg  = consumer.poll(100);
                }
                System.out.println(msg);
            }
        }
    }
}




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-and-Kafka-issue-tp5059.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message