You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "FrankYang0529 (via GitHub)" <gi...@apache.org> on 2026/02/15 04:44:39 UTC
[PR] KAFKA-19976: Deprecate streams-scala module [kafka]
FrankYang0529 opened a new pull request, #21480:
URL: https://github.com/apache/kafka/pull/21480
KIP-1244: https://cwiki.apache.org/confluence/x/r4LMFw
* Deprecate streams-scala module
* Add migration document
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19976: Deprecate streams-scala module [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #21480:
URL: https://github.com/apache/kafka/pull/21480#discussion_r2822519530
##########
streams/streams-scala/src/main/scala/org/apache/kafka/streams/scala/kstream/KTable.scala:
##########
@@ -38,6 +38,7 @@ import org.apache.kafka.streams.state.KeyValueStore
* @param inner The underlying Java abstraction for KTable
* @see `org.apache.kafka.streams.kstream.KTable`
*/
+@deprecated("Use `org.apache.kafka.streams.kstream.KTable` instead", "4.0.0")
Review Comment:
`4.0.0` -> `4.3.0`
##########
streams/streams-scala/src/main/scala/org/apache/kafka/streams/scala/serialization/Serdes.scala:
##########
@@ -23,6 +23,7 @@ import java.util.UUID
import org.apache.kafka.common.serialization.{Deserializer, Serde, Serdes => JSerdes, Serializer}
import org.apache.kafka.streams.kstream.WindowedSerdes
+@deprecated("Use org.apache.kafka.common.serialization.Serdes instead", "3.0.0")
Review Comment:
`3.0.0` -> `4.3.0`
##########
docs/streams/developer-guide/scala-migration.md:
##########
@@ -0,0 +1,104 @@
+---
+title: Migrating from Streams Scala to Java API
+description:
+weight: 16
+tags: ['kafka', 'docs']
+aliases:
+keywords:
+type: docs
+---
+
+<!--
+ 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.
+-->
+
+> **⚠️ DEPRECATION NOTICE**: The `kafka-streams-scala` library is deprecated as of Kafka 4.3
+> and will be removed in Kafka 5.0. This guide will help you migrate your Scala applications
+> to use the Java Streams API directly.
+> For more information, see [KIP-1244](https://cwiki.apache.org/confluence/x/r4LMFw).
+
+## Migration Overview
+
+The Java Streams API works well from Scala with minimal adjustments. The main differences are:
+
+1. **Use Java types directly** instead of Scala wrapper classes
+2. **Configure Serdes explicitly** via `StreamsConfig` or pass them to methods
+
+### Example: Word Count Application
+
+#### Scala Wrapper Approach (Deprecated)
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+import org.apache.kafka.streams.scala.serialization.Serdes._
+
+object WordCountScala extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+
+ val builder = new StreamsBuilder // Scala wrapper
+ val textLines: KStream[String, String] = builder.stream[String, String]("input-topic")
+
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(line => line.toLowerCase.split("\\W+"))
+ .groupBy((_, word) => word)
+ .count()
+
+ wordCounts.toStream.to("output-topic")
+
+ val streams = new KafkaStreams(builder.build(), props)
+ streams.start()
+}
+```
+
+#### Java API Approach
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.{KafkaStreams, StreamsBuilder, StreamsConfig}
+import org.apache.kafka.streams.kstream.{KStream, KTable, Produced}
+import org.apache.kafka.common.serialization.Serdes
+import scala.jdk.CollectionConverters._
+
+object WordCountJava extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+ // Configure default serdes
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.StringSerde.class)
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.StringSerde.class)
Review Comment:
ditto
##########
docs/streams/developer-guide/scala-migration.md:
##########
@@ -0,0 +1,104 @@
+---
+title: Migrating from Streams Scala to Java API
+description:
+weight: 16
+tags: ['kafka', 'docs']
+aliases:
+keywords:
+type: docs
+---
+
+<!--
+ 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.
+-->
+
+> **⚠️ DEPRECATION NOTICE**: The `kafka-streams-scala` library is deprecated as of Kafka 4.3
+> and will be removed in Kafka 5.0. This guide will help you migrate your Scala applications
+> to use the Java Streams API directly.
+> For more information, see [KIP-1244](https://cwiki.apache.org/confluence/x/r4LMFw).
+
+## Migration Overview
+
+The Java Streams API works well from Scala with minimal adjustments. The main differences are:
+
+1. **Use Java types directly** instead of Scala wrapper classes
+2. **Configure Serdes explicitly** via `StreamsConfig` or pass them to methods
+
+### Example: Word Count Application
+
+#### Scala Wrapper Approach (Deprecated)
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+import org.apache.kafka.streams.scala.serialization.Serdes._
+
+object WordCountScala extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+
+ val builder = new StreamsBuilder // Scala wrapper
+ val textLines: KStream[String, String] = builder.stream[String, String]("input-topic")
+
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(line => line.toLowerCase.split("\\W+"))
+ .groupBy((_, word) => word)
+ .count()
+
+ wordCounts.toStream.to("output-topic")
+
+ val streams = new KafkaStreams(builder.build(), props)
+ streams.start()
+}
+```
+
+#### Java API Approach
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.{KafkaStreams, StreamsBuilder, StreamsConfig}
+import org.apache.kafka.streams.kstream.{KStream, KTable, Produced}
+import org.apache.kafka.common.serialization.Serdes
+import scala.jdk.CollectionConverters._
+
+object WordCountJava extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+ // Configure default serdes
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.StringSerde.class)
Review Comment:
`Serdes.StringSerde.class` -> `Serdes.StringSerde.getClass`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19976: Deprecate streams-scala module [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #21480:
URL: https://github.com/apache/kafka/pull/21480#discussion_r2808684530
##########
docs/streams/developer-guide/scala-migration.md:
##########
@@ -0,0 +1,107 @@
+---
+title: Migrating from Streams Scala to Java API
+description:
+weight: 16
+tags: ['kafka', 'docs']
+aliases:
+keywords:
+type: docs
+---
+
+<!--
+ 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.
+-->
+
+> **⚠️ DEPRECATION NOTICE**: The `kafka-streams-scala` library is deprecated as of Kafka 4.3
+> and will be removed in Kafka 5.0. This guide will help you migrate your Scala applications
+> to use the Java Streams API directly.
+> For more information, see [KIP-1244](https://cwiki.apache.org/confluence/x/r4LMFw).
+
+## Migration Overview
+
+The Java Streams API works well from Scala with minimal adjustments. The main differences are:
+
+1. **Use Java types directly** instead of Scala wrapper classes
+2. **Configure Serdes explicitly** via `StreamsConfig` or pass them to methods
+
+### Example: Word Count Application
+
+#### Scala Wrapper Approach (Deprecated)
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountScala extends App {
+ import org.apache.kafka.streams.scala.serialization.Serdes._
+
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+
+ val builder = new StreamsBuilder // Scala wrapper
+ val textLines: KStream[String, String] = builder.stream[String, String]("input-topic")
+
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(line => line.toLowerCase.split("\\W+"))
+ .groupBy((_, word) => word)
+ .count()
+
+ wordCounts.toStream.to("output-topic")
+
+ val streams = new KafkaStreams(builder.build(), props)
+ streams.start()
+}
+```
+
+#### Java API Approach
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.{KafkaStreams, StreamsBuilder, StreamsConfig}
+import org.apache.kafka.streams.kstream.{KStream, KTable, Produced}
+import org.apache.kafka.common.serialization.Serdes
+import scala.jdk.CollectionConverters._
+
+object WordCountJava extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+ // Configure default serdes
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass.getName)
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass.getName)
+
+ val builder = new StreamsBuilder // Java StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("input-topic")
Review Comment:
we can let the compiler handle the type inference here
##########
docs/apis/_index.md:
##########
@@ -98,6 +98,10 @@ To use Kafka Streams, add the following Maven dependency to your project:
<version>4.3.0</version>
</dependency>
+> **⚠️ DEPRECATION NOTICE**: The `kafka-streams-scala` library is deprecated as of Kafka 4.3
Review Comment:
Could you move this warning message closer to the example of scala maven blcok? That way, people won't mistake it for being about java
##########
docs/streams/developer-guide/scala-migration.md:
##########
@@ -0,0 +1,107 @@
+---
+title: Migrating from Streams Scala to Java API
+description:
+weight: 16
+tags: ['kafka', 'docs']
+aliases:
+keywords:
+type: docs
+---
+
+<!--
+ 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.
+-->
+
+> **⚠️ DEPRECATION NOTICE**: The `kafka-streams-scala` library is deprecated as of Kafka 4.3
+> and will be removed in Kafka 5.0. This guide will help you migrate your Scala applications
+> to use the Java Streams API directly.
+> For more information, see [KIP-1244](https://cwiki.apache.org/confluence/x/r4LMFw).
+
+## Migration Overview
+
+The Java Streams API works well from Scala with minimal adjustments. The main differences are:
+
+1. **Use Java types directly** instead of Scala wrapper classes
+2. **Configure Serdes explicitly** via `StreamsConfig` or pass them to methods
+
+### Example: Word Count Application
+
+#### Scala Wrapper Approach (Deprecated)
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountScala extends App {
+ import org.apache.kafka.streams.scala.serialization.Serdes._
Review Comment:
could you move this import to line 51?
##########
docs/streams/developer-guide/scala-migration.md:
##########
@@ -0,0 +1,107 @@
+---
+title: Migrating from Streams Scala to Java API
+description:
+weight: 16
+tags: ['kafka', 'docs']
+aliases:
+keywords:
+type: docs
+---
+
+<!--
+ 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.
+-->
+
+> **⚠️ DEPRECATION NOTICE**: The `kafka-streams-scala` library is deprecated as of Kafka 4.3
+> and will be removed in Kafka 5.0. This guide will help you migrate your Scala applications
+> to use the Java Streams API directly.
+> For more information, see [KIP-1244](https://cwiki.apache.org/confluence/x/r4LMFw).
+
+## Migration Overview
+
+The Java Streams API works well from Scala with minimal adjustments. The main differences are:
+
+1. **Use Java types directly** instead of Scala wrapper classes
+2. **Configure Serdes explicitly** via `StreamsConfig` or pass them to methods
+
+### Example: Word Count Application
+
+#### Scala Wrapper Approach (Deprecated)
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountScala extends App {
+ import org.apache.kafka.streams.scala.serialization.Serdes._
+
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+
+ val builder = new StreamsBuilder // Scala wrapper
+ val textLines: KStream[String, String] = builder.stream[String, String]("input-topic")
+
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(line => line.toLowerCase.split("\\W+"))
+ .groupBy((_, word) => word)
+ .count()
+
+ wordCounts.toStream.to("output-topic")
+
+ val streams = new KafkaStreams(builder.build(), props)
+ streams.start()
+}
+```
+
+#### Java API Approach
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.{KafkaStreams, StreamsBuilder, StreamsConfig}
+import org.apache.kafka.streams.kstream.{KStream, KTable, Produced}
+import org.apache.kafka.common.serialization.Serdes
+import scala.jdk.CollectionConverters._
+
+object WordCountJava extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+ // Configure default serdes
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass.getName)
Review Comment:
`Serdes.StringSerde.class`
##########
docs/streams/developer-guide/scala-migration.md:
##########
@@ -0,0 +1,107 @@
+---
+title: Migrating from Streams Scala to Java API
+description:
+weight: 16
+tags: ['kafka', 'docs']
+aliases:
+keywords:
+type: docs
+---
+
+<!--
+ 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.
+-->
+
+> **⚠️ DEPRECATION NOTICE**: The `kafka-streams-scala` library is deprecated as of Kafka 4.3
+> and will be removed in Kafka 5.0. This guide will help you migrate your Scala applications
+> to use the Java Streams API directly.
+> For more information, see [KIP-1244](https://cwiki.apache.org/confluence/x/r4LMFw).
+
+## Migration Overview
+
+The Java Streams API works well from Scala with minimal adjustments. The main differences are:
+
+1. **Use Java types directly** instead of Scala wrapper classes
+2. **Configure Serdes explicitly** via `StreamsConfig` or pass them to methods
+
+### Example: Word Count Application
+
+#### Scala Wrapper Approach (Deprecated)
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountScala extends App {
+ import org.apache.kafka.streams.scala.serialization.Serdes._
+
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+
+ val builder = new StreamsBuilder // Scala wrapper
+ val textLines: KStream[String, String] = builder.stream[String, String]("input-topic")
+
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(line => line.toLowerCase.split("\\W+"))
+ .groupBy((_, word) => word)
+ .count()
+
+ wordCounts.toStream.to("output-topic")
+
+ val streams = new KafkaStreams(builder.build(), props)
+ streams.start()
+}
+```
+
+#### Java API Approach
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.{KafkaStreams, StreamsBuilder, StreamsConfig}
+import org.apache.kafka.streams.kstream.{KStream, KTable, Produced}
+import org.apache.kafka.common.serialization.Serdes
+import scala.jdk.CollectionConverters._
+
+object WordCountJava extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+ // Configure default serdes
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass.getName)
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass.getName)
Review Comment:
dtto
##########
docs/streams/developer-guide/scala-migration.md:
##########
@@ -0,0 +1,107 @@
+---
+title: Migrating from Streams Scala to Java API
+description:
+weight: 16
+tags: ['kafka', 'docs']
+aliases:
+keywords:
+type: docs
+---
+
+<!--
+ 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.
+-->
+
+> **⚠️ DEPRECATION NOTICE**: The `kafka-streams-scala` library is deprecated as of Kafka 4.3
+> and will be removed in Kafka 5.0. This guide will help you migrate your Scala applications
+> to use the Java Streams API directly.
+> For more information, see [KIP-1244](https://cwiki.apache.org/confluence/x/r4LMFw).
+
+## Migration Overview
+
+The Java Streams API works well from Scala with minimal adjustments. The main differences are:
+
+1. **Use Java types directly** instead of Scala wrapper classes
+2. **Configure Serdes explicitly** via `StreamsConfig` or pass them to methods
+
+### Example: Word Count Application
+
+#### Scala Wrapper Approach (Deprecated)
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountScala extends App {
+ import org.apache.kafka.streams.scala.serialization.Serdes._
+
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+
+ val builder = new StreamsBuilder // Scala wrapper
+ val textLines: KStream[String, String] = builder.stream[String, String]("input-topic")
+
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(line => line.toLowerCase.split("\\W+"))
+ .groupBy((_, word) => word)
+ .count()
+
+ wordCounts.toStream.to("output-topic")
+
+ val streams = new KafkaStreams(builder.build(), props)
+ streams.start()
+}
+```
+
+#### Java API Approach
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.{KafkaStreams, StreamsBuilder, StreamsConfig}
+import org.apache.kafka.streams.kstream.{KStream, KTable, Produced}
+import org.apache.kafka.common.serialization.Serdes
+import scala.jdk.CollectionConverters._
+
+object WordCountJava extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+ // Configure default serdes
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass.getName)
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass.getName)
+
+ val builder = new StreamsBuilder // Java StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("input-topic")
+
+ val wordCounts: KTable[String, java.lang.Long] = textLines
+ .flatMapValues { line =>
+ line.toLowerCase.split("\\W+").toBuffer.asJava
Review Comment:
`flatMapValues(_.toLowerCase.split("\\W+"))`
##########
docs/streams/developer-guide/scala-migration.md:
##########
@@ -0,0 +1,107 @@
+---
+title: Migrating from Streams Scala to Java API
+description:
+weight: 16
+tags: ['kafka', 'docs']
+aliases:
+keywords:
+type: docs
+---
+
+<!--
+ 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.
+-->
+
+> **⚠️ DEPRECATION NOTICE**: The `kafka-streams-scala` library is deprecated as of Kafka 4.3
+> and will be removed in Kafka 5.0. This guide will help you migrate your Scala applications
+> to use the Java Streams API directly.
+> For more information, see [KIP-1244](https://cwiki.apache.org/confluence/x/r4LMFw).
+
+## Migration Overview
+
+The Java Streams API works well from Scala with minimal adjustments. The main differences are:
+
+1. **Use Java types directly** instead of Scala wrapper classes
+2. **Configure Serdes explicitly** via `StreamsConfig` or pass them to methods
+
+### Example: Word Count Application
+
+#### Scala Wrapper Approach (Deprecated)
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountScala extends App {
+ import org.apache.kafka.streams.scala.serialization.Serdes._
+
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+
+ val builder = new StreamsBuilder // Scala wrapper
+ val textLines: KStream[String, String] = builder.stream[String, String]("input-topic")
+
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(line => line.toLowerCase.split("\\W+"))
+ .groupBy((_, word) => word)
+ .count()
+
+ wordCounts.toStream.to("output-topic")
+
+ val streams = new KafkaStreams(builder.build(), props)
+ streams.start()
+}
+```
+
+#### Java API Approach
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.{KafkaStreams, StreamsBuilder, StreamsConfig}
+import org.apache.kafka.streams.kstream.{KStream, KTable, Produced}
+import org.apache.kafka.common.serialization.Serdes
+import scala.jdk.CollectionConverters._
+
+object WordCountJava extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+ // Configure default serdes
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass.getName)
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass.getName)
+
+ val builder = new StreamsBuilder // Java StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("input-topic")
+
+ val wordCounts: KTable[String, java.lang.Long] = textLines
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19976: Deprecate streams-scala module [kafka]
Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on PR #21480:
URL: https://github.com/apache/kafka/pull/21480#issuecomment-3903700752
@chia7712 Thanks for the review. Updated it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19976: Deprecate streams-scala module [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #21480:
URL: https://github.com/apache/kafka/pull/21480#discussion_r2824855558
##########
docs/streams/developer-guide/scala-migration.md:
##########
@@ -0,0 +1,104 @@
+---
+title: Migrating from Streams Scala to Java API
+description:
+weight: 16
+tags: ['kafka', 'docs']
+aliases:
+keywords:
+type: docs
+---
+
+<!--
+ 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.
+-->
+
+> **⚠️ DEPRECATION NOTICE**: The `kafka-streams-scala` library is deprecated as of Kafka 4.3
+> and will be removed in Kafka 5.0. This guide will help you migrate your Scala applications
+> to use the Java Streams API directly.
+> For more information, see [KIP-1244](https://cwiki.apache.org/confluence/x/r4LMFw).
+
+## Migration Overview
+
+The Java Streams API works well from Scala with minimal adjustments. The main differences are:
+
+1. **Use Java types directly** instead of Scala wrapper classes
+2. **Configure Serdes explicitly** via `StreamsConfig` or pass them to methods
+
+### Example: Word Count Application
+
+#### Scala Wrapper Approach (Deprecated)
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+import org.apache.kafka.streams.scala.serialization.Serdes._
+
+object WordCountScala extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+
+ val builder = new StreamsBuilder // Scala wrapper
+ val textLines: KStream[String, String] = builder.stream[String, String]("input-topic")
+
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(line => line.toLowerCase.split("\\W+"))
+ .groupBy((_, word) => word)
+ .count()
+
+ wordCounts.toStream.to("output-topic")
+
+ val streams = new KafkaStreams(builder.build(), props)
+ streams.start()
+}
+```
+
+#### Java API Approach
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.{KafkaStreams, StreamsBuilder, StreamsConfig}
+import org.apache.kafka.streams.kstream.{KStream, KTable, Produced}
+import org.apache.kafka.common.serialization.Serdes
+import scala.jdk.CollectionConverters._
+
+object WordCountJava extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+ // Configure default serdes
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.StringSerde.class)
Review Comment:
Both would work. Personally, I actually thing `.class` is better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19976: Deprecate streams-scala module [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #21480:
URL: https://github.com/apache/kafka/pull/21480
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19976: Deprecate streams-scala module [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #21480:
URL: https://github.com/apache/kafka/pull/21480#discussion_r2825312566
##########
docs/streams/developer-guide/scala-migration.md:
##########
@@ -0,0 +1,104 @@
+---
+title: Migrating from Streams Scala to Java API
+description:
+weight: 16
+tags: ['kafka', 'docs']
+aliases:
+keywords:
+type: docs
+---
+
+<!--
+ 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.
+-->
+
+> **⚠️ DEPRECATION NOTICE**: The `kafka-streams-scala` library is deprecated as of Kafka 4.3
+> and will be removed in Kafka 5.0. This guide will help you migrate your Scala applications
+> to use the Java Streams API directly.
+> For more information, see [KIP-1244](https://cwiki.apache.org/confluence/x/r4LMFw).
+
+## Migration Overview
+
+The Java Streams API works well from Scala with minimal adjustments. The main differences are:
+
+1. **Use Java types directly** instead of Scala wrapper classes
+2. **Configure Serdes explicitly** via `StreamsConfig` or pass them to methods
+
+### Example: Word Count Application
+
+#### Scala Wrapper Approach (Deprecated)
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+import org.apache.kafka.streams.scala.serialization.Serdes._
+
+object WordCountScala extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+
+ val builder = new StreamsBuilder // Scala wrapper
+ val textLines: KStream[String, String] = builder.stream[String, String]("input-topic")
+
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(line => line.toLowerCase.split("\\W+"))
+ .groupBy((_, word) => word)
+ .count()
+
+ wordCounts.toStream.to("output-topic")
+
+ val streams = new KafkaStreams(builder.build(), props)
+ streams.start()
+}
+```
+
+#### Java API Approach
+
+```scala
+import java.util.Properties
+
+import org.apache.kafka.streams.{KafkaStreams, StreamsBuilder, StreamsConfig}
+import org.apache.kafka.streams.kstream.{KStream, KTable, Produced}
+import org.apache.kafka.common.serialization.Serdes
+import scala.jdk.CollectionConverters._
+
+object WordCountJava extends App {
+ val props = new Properties()
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount")
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
+ // Configure default serdes
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.StringSerde.class)
Review Comment:
Ugh, I think both of us are just Scala tourists here. 😅 Since the example is written in Scala, the correct way should actually be `classOf[Serdes.StringSerde]`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19976: Deprecate streams-scala module [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on PR #21480:
URL: https://github.com/apache/kafka/pull/21480#issuecomment-3941429623
@FrankYang0529 could you rebase code to run CI again?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org