Kafka Activity
This activity publishes messages on a topic in a Kafka cluster.
Flogo CLI
flogo install github.com/project-flogo/messaging-contrib/kafka/activity
Configuration
Settings:
Name |
Type |
Description |
connection |
any |
The connection object which is use to connect to kafka - REQUIRED Connection |
topic |
string |
The Kafka topic on which to place the message - REQUIRED |
Name |
Type |
Description |
message |
string |
The message to send |
Output:
Name |
Type |
Description |
partition |
int32 |
Documents the partition that the message was placed on |
offSet |
int64 |
Documents the offset for the message |
Examples
The below example sends Hello From Flogo
to a Kafka Broker running on localhost:
{
"id": "publish_kafka_message",
"name": "Publish Message to Kafka",
"activity": {
"ref": "github.com/project-flogo/contrib/activity/kafka",
"settings": {
"brokerUrls" : "localhost:9092",
"topic" : "syslog"
},
"input": {
"message" : "Hello From Flogo"
}
}
}
Development
Testing
To run tests first set up the Kafka broker using the docker-compose file given below:
version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper:3.4.6
expose:
- "2181"
kafka:
image: wurstmeister/kafka:2.11-2.0.0
depends_on:
- zookeeper
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
Then run the following command:
go test