I'm new to Apache Kafka. I'm trying to run their DemoApp
in StreamAPI
section and I get the following error in cmd:
The syntax of the command is incorrect.
Here're the variants I've used:
Variant 1:
bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic streams-wordcount-output --from-beginning --formatter kafka.tools.DefaultMessageFormatter --property print.key=true --property print.value=true
Variant 2:
bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic streams-wordcount-output --from-beginning --formatter kafka.tools.DefaultMessageFormatter --consumer.config config\console-consumer.properties
console-consumer.properties
contains the same properties as in the first variant.
I'm using Windows 10 with both PowerShell and classic cmd results in same error on execution of the batch file.
Here's the working example (the use Linux):
https://kafka.apache.org/27/documentation/streams/quickstart#quickstart_streams_start
Without formatter and configuration I can't see the message properly formatted (as obvious :).
UPDATE 1:
The debugged batch file output:
C:\Users\MyUserName\kafka_2.13-2.7.0>bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic streams-wordcount-output --from-beginning --formatter kafka.tools.DefaultMessageFormatter --consumer.config config\console-consumer.properties
SetLocal
set KAFKA_HEAP_OPTS=-Xmx512M
"C:\Users\MyUserName\kafka_2.13-2.7.0\bin\windows\kafka-run-class.bat" kafka.tools.ConsoleConsumer --bootstrap-server localhost:9092 --topic streams-wordcount-output --from-beginning --formatter kafka.tools.DefaultMessageFormatter --consumer.config config\console-consumer.properties
The syntax of the command is incorrect.
UPDATE 2:
The second debugged batch file output as asked by Mofi (only the last page):
set DEFAULT_DEBUG_SUSPEND_FLAG=n
rem Set Debug options if enabled
IF [""] NEQ [""] (
IF [""] EQU [""] (set JAVA_DEBUG_PORT=5005 )
IF [""] EQU [""] (set DEBUG_SUSPEND_FLAG=n )
set DEFAULT_JAVA_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=!DEBUG_SUSPEND_FLAG!,address=!JAVA_DEBUG_PORT!
IF [""] EQU [""] (set JAVA_DEBUG_OPTS=!DEFAULT_JAVA_DEBUG_OPTS! )
echo Enabling Java debug options: !JAVA_DEBUG_OPTS!
set KAFKA_OPTS=!JAVA_DEBUG_OPTS! !KAFKA_OPTS!
)
rem Which java to use
IF ["C:\Program Files\Java\jdk-14"] EQU [""] (set JAVA=java ) ELSE (set JAVA="C:\Program Files\Java\jdk-14/bin/java" )
rem Memory options
IF ["-Xmx512M"] EQU [""] (set KAFKA_HEAP_OPTS=-Xmx256M )
rem JVM performance options
IF [""] EQU [""] (set KAFKA_JVM_PERFORMANCE_OPTS=-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -Djava.awt.headless=true )
IF not defined CLASSPATH (
echo Classpath is empty. Please build the project first e.g. by running 'gradlew jarAll'
EXIT /B 2
)
The syntax of the command is incorrect.