/* | |
* Licensed to the Apache Software Foundation (ASF) under one or more | |
* contributor license agreements. See the NOTICE file distributed with | |
* this work for additional information regarding copyright ownership. | |
* The ASF licenses this file to You under the Apache License, Version 2.0 | |
* (the "License"); you may not use this file except in compliance with | |
* the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
package org.apache.kafka.streams; | |
import org.apache.kafka.common.serialization.Serdes; | |
import java.util.Properties; | |
public class StreamsDSLExample { | |
public static void main(String[] args) { | |
final Properties properties = new Properties(); | |
properties.setProperty(StreamsConfig.APPLICATION_ID_CONFIG, "test-application"); | |
properties.setProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); | |
properties.setProperty(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); | |
properties.setProperty(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); | |
final StreamsBuilder builder = new StreamsBuilder(); | |
builder.<String, String>stream("input") | |
.filter((k,v) -> v.endsWith("FOO")) | |
.mapValues(v -> v.substring(0,3)) | |
.to("output"); | |
final Topology topology = builder.build(properties); | |
final KafkaStreams streams = new KafkaStreams(topology, properties); | |
streams.start() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment