brew install librdkafka
apt install librdkafka-dev
yum install http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/l/librdkafka-0.11.5-1.el7.x86_64.rpm
yum install http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/l/librdkafka-devel-0.11.5-1.el7.x86_64.rpm
export GOPATH=[path to goDir workspace]
export KAFKAMESSAGEQ_HOME=$GOPATH/src/KafkaMessageQ-API
go run main.go
Note: Asynchronous in KafkaMessageQ meaning producer produces the messages to brokers by
using synchronous send message of the kafka client library, KafkaMessageQ only using
synchronous of the kafka client library.
curl localhost:7890/api/producer -d '{ "aWait":false, "topics":{"sending": "test-req"}, "message":{"greet":"Hello World"} }'
curl localhost:7890/api/consumer -d '{ "groupID":"test", "autoOffsetReset":"earliest" , "topics":["test-req"]}'
that is your any data in json format.
for producer topics isn't list but it's json format, below is the fields of topics.
-
It's the destination topic that you want to send message to.
-
note: not allowed redeclare name of sending Similar on above but it waits to receive message from another topic.
if true KafkaMessageQ will block process until receive result message, false KafkaMessageQ will not wait receive message by default.
only allowed producer.
-
default 30s
-
default 30s
-
default 10s
note: only allowed to producer that aWait set to false
clientID is the UUID used to checking where messages come from
it may come from services[i] of services[1],services[2],...,services[n] that subscribe at the same topic.
curl -XPOST localhost:7890/api/producer \
-d '{"aWait":false, "message":{[JSON]}, \
"topics":{"sending":"[SEND_TO_TOPIC]"}}'
curl -XPOST localhost:7890/api/producer \
-d '{"aWait":true, "message":{[JSON]}, \
"topics":{"sending":"[SEND_TO_TOPIC]","receiving":"[RECEIVE_FROM_TOPIC]"}'
curl -XPOST localhost:7890/api/producer \
-d '{"aWait":[Boolean], "message":{[JSON]}, \
"topics":{"sending":"[SEND_TO_TOPIC]"},"timeout": 10}'
curl -XPOST localhost:7890/api/producer \
-d '{"aWait":[Boolean], "message":{[JSON]}, \
"topics":{"sending":"[SEND_TO_TOPIC]"},"timeoutProduce": 30}'
curl -XPOST localhost:7890/api/producer \
-d '{"aWait":[Boolean], "message":{[JSON]}, \
"topics":{"sending":"[SEND_TO_TOPIC]", \
"receiving":"[RECEIVE_TOPIC_FROM]"},"timeoutProduce": 10, \
"timeoutConsume": 30,"timeout": 10}'
curl -XPOST localhost:7890/api/producer \
-d '{"aWait":[Boolean], "message":{[JSON][, "clientID":"[UUID]" ]}, \
"topics":{"sending":"[SEND_TO_TOPIC]"}}'
name of service group which using consume message
KafkaMessageQ allowed to subscribe multiple topics by default if and only if you let topics list to empty so that will subscribe all topics
FLAGS : earliest, latest by default
earliest: automatically reset the offset to the earliest offset or oldest messages
latest: automatically reset the offset to the latest offset or newest messages
curl -XPOST localhost:7890/api/consumer \
-d '{"topics":["topice1","topic2","topic3"], "groupID":"GROUP_NAME","autoOffsetReset":"[FLAGS]"}'
NOTE THAT : you must create your topics name as follows the first letter
that can be an upper case or lower case after first letter
can be digit or dash character or letters
CASE SUPPORT :
description symbol :
+ <== one or more
* <== empty or more
[a-zA-Z] <== lower case or upper case
[0-9-] <== digit 0 to 9 and allowed dash character
[a-zA-Z]+[0-9-]*
curl -XPOST localhost:7890/api/consumer \
-d '{"topics":[], "groupID":"GROUP_NAME","autoOffsetReset":"[FLAGS]"}'