com.github.jcustenborder.kafka:kafka-jaxb

A pom for deploying to maven central.

License

License

GroupId

GroupId

com.github.jcustenborder.kafka
ArtifactId

ArtifactId

kafka-jaxb
Last Version

Last Version

0.0.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

A pom for deploying to maven central.

Download kafka-jaxb

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.jcustenborder.kafka/kafka-jaxb/ -->
<dependency>
    <groupId>com.github.jcustenborder.kafka</groupId>
    <artifactId>kafka-jaxb</artifactId>
    <version>0.0.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.jcustenborder.kafka/kafka-jaxb/
implementation 'com.github.jcustenborder.kafka:kafka-jaxb:0.0.1.2'
// https://jarcasting.com/artifacts/com.github.jcustenborder.kafka/kafka-jaxb/
implementation ("com.github.jcustenborder.kafka:kafka-jaxb:0.0.1.2")
'com.github.jcustenborder.kafka:kafka-jaxb:jar:0.0.1.2'
<dependency org="com.github.jcustenborder.kafka" name="kafka-jaxb" rev="0.0.1.2">
  <artifact name="kafka-jaxb" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.jcustenborder.kafka', module='kafka-jaxb', version='0.0.1.2')
)
libraryDependencies += "com.github.jcustenborder.kafka" % "kafka-jaxb" % "0.0.1.2"
[com.github.jcustenborder.kafka/kafka-jaxb "0.0.1.2"]

Dependencies

compile (1)

Group / Artifact Type Version
javax.xml.bind : jaxb-api jar 2.2.12

provided (2)

Group / Artifact Type Version
org.apache.kafka : kafka-clients jar 0.10.2.1
org.slf4j : slf4j-api jar 1.7.21

test (4)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-engine jar 5.0.0-M4
org.junit.jupiter : junit-jupiter-api jar 5.0.0-M4
org.mockito : mockito-core jar 1.10.19
ch.qos.logback : logback-classic jar 1.1.8

Project Modules

There are no modules declared in this project.

Introduction

Sometimes you just need XML. This project is for one of those times where you just need some xml support in Apache Kafka. The goal of this project is to aid with storing XML data in Apache Kafka.

Maven Central

Producing Data

Properties properties = new Properties();
properties.put(JAXBSerializerConfig.JAXB_FORMATTED_OUTPUT_CONF, "true");
properties.put(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, "kafka:9092");
properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, IntegerSerializer.class.toString());
properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JAXBSerializer.class.toString());
Producer<Integer, TestPojo> producer = new KafkaProducer<>(properties);

Consuming Data

Properties properties = new Properties();
properties.put(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, "kafka:9092");
properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, IntegerDeserializer.class.toString());
properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JAXBDeserializer.class.toString());
Consumer<Integer, TestPojo> consumer = new KafkaConsumer<>(properties);

Example Model

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class TestPojo {
  String name;
  int age;
  int id;

  public String getName() {
    return name;
  }

  @XmlElement
  public void setName(String name) {
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  @XmlElement
  public void setAge(int age) {
    this.age = age;
  }

  public int getId() {
    return id;
  }

  @XmlAttribute
  public void setId(int id) {
    this.id = id;
  }
}

Versions

Version
0.0.1.2