Skip to content

phyze/kafkaMessageQ-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kafkaMessageQ-API

Index


Installing


macOS
brew install librdkafka
Ubuntu
apt install librdkafka-dev
centos7+/redhat7 +
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

Environment Variable

export GOPATH=[path to goDir workspace]
export KAFKAMESSAGEQ_HOME=$GOPATH/src/KafkaMessageQ-API

Run

KafkaMessageQ Application

go run main.go

Quick start

Producer Asynchronous

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"} }'
Consumer
curl localhost:7890/api/consumer -d '{ "groupID":"test", "autoOffsetReset":"earliest" , "topics":["test-req"]}'

Document

Producer

message

that is your any data in json format.

topics

for producer topics isn't list but it's json format, below is the fields of topics.

  • sending

    It's the destination topic that you want to send message to.

  • receiveing

    note: not allowed redeclare name of sending Similar on above but it waits to receive message from another topic.

Options

aWait

if true KafkaMessageQ will block process until receive result message, false KafkaMessageQ will not wait receive message by default.

timeouts

only allowed producer.

  • timeout

    default 30s

  • timeoutConsume

    default 30s

  • timeoutProduce

    default 10s

clientID

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.

Examples

asynchronous
curl -XPOST localhost:7890/api/producer  \ 
-d '{"aWait":false, "message":{[JSON]}, \ 
"topics":{"sending":"[SEND_TO_TOPIC]"}}'
synchronous
curl -XPOST localhost:7890/api/producer  \ 
-d '{"aWait":true, "message":{[JSON]}, \ 
"topics":{"sending":"[SEND_TO_TOPIC]","receiving":"[RECEIVE_FROM_TOPIC]"}'
timeouts
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}'
clientID
curl -XPOST localhost:7890/api/producer  \ 
-d '{"aWait":[Boolean], "message":{[JSON][, "clientID":"[UUID]" ]}, \ 
"topics":{"sending":"[SEND_TO_TOPIC]"}}'

Consumer

groupID

name of service group which using consume message

topics

KafkaMessageQ allowed to subscribe multiple topics by default if and only if you let topics list to empty so that will subscribe all topics

option

autoOffsetReset

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

Examples

subscribe multi-topics
curl -XPOST localhost:7890/api/consumer \ 
-d '{"topics":["topice1","topic2","topic3"], "groupID":"GROUP_NAME","autoOffsetReset":"[FLAGS]"}' 
subscribe all topics
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]"}' 

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published