Giter Club home page Giter Club logo

kafkaclient-avrosr's Introduction

KafkaAvroSRClient

To produce messages to a Kafka topic using avro schema as defined in hortonworks schema registry (the example is for a secure cluster)

  1. Create a producer config file, with its contents like below. let's call it /tmp/producer.conf:

acks=all
sasl.kerberos.service.name=kafka
zookeeper.set.acl=true
kafkastore.security.protocol=SASL_PLAINTEXT
kafkastore.sasl.mechanism=GSSAPI
kafkastore.sasl.kerberos.service.name=kafka
security.protocol=SASL_PLAINTEXT
schema.registry.url=http://hdf-node3.hwx-labs.com:7788/api/v1
bootstrap.servers=hdf-node3.hwx-labs.com:6667
topic=packettrace
ignore.invalid.messages=false
compression.type=none


  1. Prepare the data in json format. For example: packettrace.json

{"src":"10.0.6.3","dest":"stark","destport": 12345 }
{"src":"wolverine","dest":"stark","destport": 2245 }


  1. Prepare the schema. Let's call it packettrace.avsc

{
"type" : "record",
"name" : "packettrace",
"namespace" : "hortonworks.hdp.support.packettrace",
"fields" : [
{ "name" : "src" , "type" : "string" },
{ "name" : "dest" , "type" : "string" },
{ "name" : "destport" , "type" : "int" }
]
}


  1. Register the new schema to Schema registry with the same name as that of topic.

  1. The pom.xml is defined to use shaded plugin. Run the program as follows:

java /tmp -Djava.security.auth.login.config=/etc/kafka/conf/kafka_client_jaas.conf -jar /tmp/KafkaClient-avroSR-0.0.1-SNAPSHOT.jar com.hwxlabs.registry.KafkaAvro.KafkaAvroSRClient -sm -p /tmp/producer.conf -d /tmp/packettrace.json -s /tmp/packettrace.avsc

This is a bit modified version of https://github.com/hortonworks/registry/blob/HDF-2.1.0.0/examples/schema-registry/avro/src/main/java/com/hortonworks/registries/schemaregistry/examples/avro/TruckEventsKafkaAvroSerDesApp.java

kafkaclient-avrosr's People

Contributors

rmaruthiyodan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.