Create Producer in Java.
Before running the Java project, make sure
1.Zookeeper is running
2.Kafka is running
3.Topic is created
4.Consumer is running so you can see the output
Problem1:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.ht... for further details.
Solution:
In the dependencies under build.gradle, I have
// https://mvnrepository.com/artifact/org.slf4j/slf4j-simple
testImplementation 'org.slf4j:slf4j-simple:1.7.36'
【Kafka Series 4 - Java Project】Should remove the 'test' and make it
// https://mvnrepository.com/artifact/org.slf4j/slf4j-simple
implementation 'org.slf4j:slf4j-simple:1.7.36'
Refresh the project, run again
Problem2:
org.apache.kafka.clients.NetworkClient - [Consumer clientId=consumer-my-second-application-1, groupId=my-second-application] Node -1 disconnected.
Solution:
Typo in server.
Also could be Zookeeper and Kafka not running.
Problem3:
Created Consumer in Java, run, not retriving the historical messages.
Solution:
It's because offsets for your group id got committed.
Change the group id. (I updated from String groupId = "my-second-application"; to String groupId = "my-second-application-2"; )
Partition Strategies
RangeAssignor
RoundRobin
StickyAssignor
CorperativeStickyAssignor
The default assignor is [RangeAssignor,CorperativeStickyAssignor]
Problem4:
Incompatible types. Found: 'io.conduktor.demos.kafka.wikimedia.WikimediaChangeHandler', required: 'java.beans.EventHandler'
Solution:
文章图片
there are 2 types, choose com.launchdarkly.eventsource