Skip to content

Event model in Java

Fernando Benjamin edited this page May 18, 2016 · 13 revisions

The java client use Jackson for serializing/deserializing json content, to use this default serialization logic you need to use the Jackson annotations on your Event model:

  • Annotate the constructor with the Jackson @JsonCreater.

  • Annotate each constructor parameter with @JsonProperty.


Create your Event Model
import org.zalando.nakadi.client.java.model.Event;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

public class MeetingsEvent implements Event {
    private final String date;
    private final String topic;

    @JsonCreator
    public MeetingsEvent(@JsonProperty("date") String date, 
                        @JsonProperty("topic") String topic) {
        this.date = date;
        this.topic = topic;
    }

    public String getDate() {
        return date;
    }

    public String getTopic() {
        return topic;
    }

}
Table of contents
How to steps(Java)
  1. How to use it in your project?
  1. How to subscribe to Events?
  1. How to publish an event?
How to steps(Scala)
  1. How to use it in your project?
  1. How to subscribe to Events?
  1. How to publish an event?
Clone this wiki locally