Java Code Examples for org.apache.kafka.streams.integration.utils.EmbeddedKafkaCluster

The following examples show how to use org.apache.kafka.streams.integration.utils.EmbeddedKafkaCluster. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@BeforeAll
static void setUp() throws InterruptedException, IOException {
    //Start Kafka Cluster
    kafkaCluster = new EmbeddedKafkaCluster(NUM_BROKERS);
    kafkaCluster.start();


    //Create topics
    kafkaCluster.createTopic(AppConfigs.impressionTopic);
    kafkaCluster.createTopic(AppConfigs.clicksTopic);
    kafkaCluster.createTopic(AppConfigs.outputTopic);

    //Create and start Streams application
    Properties properties = new Properties();
    properties.put(StreamsConfig.APPLICATION_ID_CONFIG,
        AppConfigs.applicationID);
    properties.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG,
        kafkaCluster.bootstrapServers());
    properties.put(StreamsConfig.STATE_DIR_CONFIG,
        AppConfigs.stateStoreLocationUT);

    StreamsBuilder builder = new StreamsBuilder();
    AppTopology.withBuilder(builder);
    Topology topology = builder.build();

    streams = new KafkaStreams(topology, properties);
    streams.start();
}