Currently, I use Maven with io.fabric8 docker-maven-plugin in order to automatically spin up Kafka and ZooKeeper. This is my current configuration which works fine:
<properties>
<zookeeper.port>2181</zookeeper.port>
<kafka.host>127.0.0.1</kafka.host>
<kafka.port>9092</kafka.port>
</properties>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven-plugin.version}</version>
<configuration>
<showLogs>true</showLogs>
<images>
<image>
<name>wurstmeister/zookeeper:${zookeeper.version}</name>
<alias>zookeeper</alias>
<run>
<ports>
<port>${zookeeper.port}:2181</port>
</ports>
</run>
</image>
<image>
<name>wurstmeister/kafka:${kafka.version}</name>
<alias>kafka</alias>
<run>
<ports>
<port>${kafka.port}:9092</port>
</ports>
<links>
<link>zookeeper:zookeeper</link>
</links>
<env>
<KAFKA_ADVERTISED_HOST_NAME>${local.ip}
</KAFKA_ADVERTISED_HOST_NAME>
<KAFKA_ADVERTISED_PORT>${kafka.port}</KAFKA_ADVERTISED_PORT>
<KAFKA_ZOOKEEPER_CONNECT>zookeeper:2181</KAFKA_ZOOKEEPER_CONNECT>
<KAFKA_MESSAGE_MAX_BYTES>15000000</KAFKA_MESSAGE_MAX_BYTES>
</env>
</run>
</image>
<image>
<name>confluentinc/cp-ksql-server:5.0.0</name>
<alias>cp-ksql-server</alias>
<run>
<ports>
<port>8088:8088</port>
</ports>
<links>
<link>kafka:kafka</link>
</links>
<env>
<KSQL_BOOTSTRAP_SERVERS>${local.ip}:9092</KSQL_BOOTSTRAP_SERVERS>
<KSQL_LISTENERS>http://0.0.0.0:8088/</KSQL_LISTENERS>
<KSQL_KSQL_SERVICE_ID>confluent_test_2</KSQL_KSQL_SERVICE_ID>
</env>
</run>
</image>
</images>
</configuration>
</plugin>
Right now I need more flexibility and monitoring tools in order to be able to properly analyze my local Kafka instance and this is why I decide to start using All-In-One Confluent Platform https://docs.confluent.io/current/quickstart/ce-docker-quickstart.html
I performed the steps described in the documentation above and was able to run Confluent Platform via docker-compose up -d
command on the following docker-compose.yml
https://github.com/confluentinc/cp-docker-images/tree/master/examples/cp-all-in-one. After that I was able to access Confluent Control Center on http://localhost:9021
My application is also starts but messages are not sending or consumed properly. This is the log:
2018-08-25 20:54:33.786 INFO 11304 --- [nio-8080-exec-1] o.a.kafka.common.utils.AppInfoParser : Kafka version : 1.1.0
2018-08-25 20:54:33.786 INFO 11304 --- [nio-8080-exec-1] o.a.kafka.common.utils.AppInfoParser : Kafka commitId : fdcf75ea326b8e07
2018-08-25 20:54:33.794 INFO 11304 --- [ad | producer-1] org.apache.kafka.clients.Metadata : Cluster ID: NCbZ7abTTdu6SQHhthMbIw
2018-08-25 20:54:33.827 INFO 11304 --- [nio-8080-exec-1] c.p.domain.service.post.PostServiceImpl : Message sent to the post creation queue: Post [id=5b8197d9e67db62c28ebe8d5, status=PENDING, externalPostId=2bdbd597-cc30-4478-b946-e873c8d53eec, chatName= ....]
2018-08-25 20:55:03.875 ERROR 11304 --- [ad | producer-1] o.s.k.support.LoggingProducerListener : Exception thrown when sending a message with key='null' and payload='Post [id=5b8197d9e67db62c28ebe8d5, status=PENDING, externalPostId=2bdbd597-cc30-4478-b946-e873c8d53e...' to topic post.send:
org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for post.send-0: 30047 ms has passed since batch creation plus linger time
I can see my topics there:
What may be wrong there and how to fix it ?
UPDATED
I enabled the DEBUG logs on Kafka in my application and right now can see the following error:
java.io.IOException: Can't resolve address: broker:9092
at org.apache.kafka.common.network.Selector.doConnect(Selector.java:235) ~[kafka-clients-1.1.0.jar:na]
at org.apache.kafka.common.network.Selector.connect(Selector.java:214) ~[kafka-clients-1.1.0.jar:na]
at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:793) [kafka-clients-1.1.0.jar:na]
at org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:230) [kafka-clients-1.1.0.jar:na]
at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.sendEligibleCalls(KafkaAdminClient.java:792) [kafka-clients-1.1.0.jar:na]
at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.run(KafkaAdminClient.java:1002) [kafka-clients-1.1.0.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
Caused by: java.nio.channels.UnresolvedAddressException: null
at sun.nio.ch.Net.checkAddress(Net.java:101) ~[na:1.8.0_171]
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:622) ~[na:1.8.0_171]
at org.apache.kafka.common.network.Selector.doConnect(Selector.java:233) ~[kafka-clients-1.1.0.jar:na]
... 6 common frames omitted
"Expiring x record(s) for topic-partition: XX ms has passed since batch creation"
is a issue with either the broker or the producer. Are you seeing any logs from either that would indicate an issue? How many messages are you sending at once? Kafka Producer will batch records, so you need to send maybe 100, or at the very least set a while loop - OneCricketeer