Search in sources :

Example 1 with SessionWindowedDeserializer

use of org.apache.kafka.streams.kstream.SessionWindowedDeserializer in project kafka by apache.

the class KStreamAggregationIntegrationTest method receiveMessages.

private <K, V> List<KeyValueTimestamp<K, V>> receiveMessages(final Deserializer<K> keyDeserializer, final Deserializer<V> valueDeserializer, final Class innerClass, final int numMessages) throws Exception {
    final String safeTestName = safeUniqueTestName(getClass(), testName);
    final Properties consumerProperties = new Properties();
    consumerProperties.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, CLUSTER.bootstrapServers());
    consumerProperties.setProperty(ConsumerConfig.GROUP_ID_CONFIG, "group-" + safeTestName);
    consumerProperties.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
    consumerProperties.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, keyDeserializer.getClass().getName());
    consumerProperties.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, valueDeserializer.getClass().getName());
    consumerProperties.put(StreamsConfig.WINDOW_SIZE_MS_CONFIG, 500L);
    if (keyDeserializer instanceof TimeWindowedDeserializer || keyDeserializer instanceof SessionWindowedDeserializer) {
        consumerProperties.setProperty(StreamsConfig.WINDOWED_INNER_CLASS_SERDE, Serdes.serdeFrom(innerClass).getClass().getName());
    }
    return IntegrationTestUtils.waitUntilMinKeyValueWithTimestampRecordsReceived(consumerProperties, outputTopic, numMessages, 60 * 1000);
}
Also used : Properties(java.util.Properties) TimeWindowedDeserializer(org.apache.kafka.streams.kstream.TimeWindowedDeserializer) SessionWindowedDeserializer(org.apache.kafka.streams.kstream.SessionWindowedDeserializer)

Example 2 with SessionWindowedDeserializer

use of org.apache.kafka.streams.kstream.SessionWindowedDeserializer in project kafka by apache.

the class KStreamAggregationIntegrationTest method receiveMessagesWithTimestamp.

private <K, V> List<KeyValueTimestamp<K, V>> receiveMessagesWithTimestamp(final Deserializer<K> keyDeserializer, final Deserializer<V> valueDeserializer, final Class innerClass, final int numMessages) throws Exception {
    final String safeTestName = safeUniqueTestName(getClass(), testName);
    final Properties consumerProperties = new Properties();
    consumerProperties.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, CLUSTER.bootstrapServers());
    consumerProperties.setProperty(ConsumerConfig.GROUP_ID_CONFIG, "group-" + safeTestName);
    consumerProperties.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
    consumerProperties.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, keyDeserializer.getClass().getName());
    consumerProperties.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, valueDeserializer.getClass().getName());
    consumerProperties.put(StreamsConfig.WINDOW_SIZE_MS_CONFIG, 500L);
    if (keyDeserializer instanceof TimeWindowedDeserializer || keyDeserializer instanceof SessionWindowedDeserializer) {
        consumerProperties.setProperty(StreamsConfig.WINDOWED_INNER_CLASS_SERDE, Serdes.serdeFrom(innerClass).getClass().getName());
    }
    return IntegrationTestUtils.waitUntilMinKeyValueWithTimestampRecordsReceived(consumerProperties, outputTopic, numMessages, 60 * 1000);
}
Also used : Properties(java.util.Properties) TimeWindowedDeserializer(org.apache.kafka.streams.kstream.TimeWindowedDeserializer) SessionWindowedDeserializer(org.apache.kafka.streams.kstream.SessionWindowedDeserializer)

Aggregations

Properties (java.util.Properties)2 SessionWindowedDeserializer (org.apache.kafka.streams.kstream.SessionWindowedDeserializer)2 TimeWindowedDeserializer (org.apache.kafka.streams.kstream.TimeWindowedDeserializer)2