October 20th, Q&A session: Get you issues solved and questions answered!

GitHub logo
Edit

RocketMQ Streamer

This streamer module provides streaming from Apache RocketMQ to Ignite.

To use Ignite RocketMQ Streamer module

  1. Import it to your Maven project. If you are using Maven to manage dependencies of your project, you can add an Ignite RocketMQ module dependency like this (replace ${ignite.version} with actual Ignite version you are interested in):

    <project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                            http://maven.apache.org/xsd/maven-4.0.0.xsd">
        ...
        <dependencies>
            ...
            <dependency>
                <groupId>org.apache.ignite</groupId>
                <artifactId>ignite-rocketmq</artifactId>
                <version>${ignite.version}</version>
            </dependency>
            ...
        </dependencies>
        ...
    </project>
  2. Implement either StreamSingleTupleExtractor or StreamMultipleTupleExtractor for the streamer (shown as MyTupleExtractor in the code sample below). For a simple implementation, refer to RocketMQStreamerTest.java.

  3. Initialize and start the streamer

    IgniteDataStreamer<String, byte[]> dataStreamer = ignite.dataStreamer(MY_CACHE));
    
    dataStreamer.allowOverwrite(true);
    dataStreamer.autoFlushFrequency(10);
    
    streamer = new RocketMQStreamer<>();
    
    //configure.
    streamer.setIgnite(ignite);
    streamer.setStreamer(dataStreamer);
    streamer.setNameSrvAddr(NAMESERVER_IP_PORT);
    streamer.setConsumerGrp(CONSUMER_GRP);
    streamer.setTopic(TOPIC_NAME);
    streamer.setMultipleTupleExtractor(new MyTupleExtractor());
    
    streamer.start();
    
    ...
    
    // stop on shutdown
    streamer.stop();
    
    dataStreamer.close();

Refer to the Javadocs for more info on the available options.