https://github.com/myxof/kafka
It simply shows how to write codes using kafka API
https://github.com/myxof/kafka
Last synced: 9 months ago
JSON representation
It simply shows how to write codes using kafka API
- Host: GitHub
- URL: https://github.com/myxof/kafka
- Owner: MyXOF
- Created: 2015-10-20T16:00:34.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-09T13:05:03.000Z (over 9 years ago)
- Last Synced: 2025-02-16T03:35:51.361Z (11 months ago)
- Language: Java
- Homepage:
- Size: 15.8 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# kafka
It simply shows how to write code using kafka API
Before using Kafka API, you should carefully read offcial documentation(http://kafka.apache.org/documentation.html).
For Kafka producer, you only need to concern the function below
/**
* send message to server
* @param topic
* @param key decide which partition to send
* @param message
* @throws IOException
*/
public void sendMessage(String topic, String key, String message)
For Kafka consumer, you need to manage lots of complex things.
/**
* fetch message set from server
* @param topic
* @param partition
* @return FetchResponse contains message set
*/
public FetchResponse consumeTopic(String topic,int partition)
This method helpes to get message from server
/**
* @param partitionCommit contains partition and topic to commit to
* @param offset current offset which has been consumed
* @param commitMetadata commit string
*/
public void commitOffsetToKafka(TopicAndPartition partitionCommit,long offset,String commitMetadata)
This method helps you commit offset which you have consumed to kafka server. Next time, you will fetch message from the offset
For config you can modify at /conf and see http://kafka.apache.org/documentation.html#configuration