Skip to content

Instantly share code, notes, and snippets.

@kanuku
Created May 24, 2016 12:39
Show Gist options
  • Save kanuku/aaa19261e7b70faf98acc9534e89901f to your computer and use it in GitHub Desktop.
Save kanuku/aaa19261e7b70faf98acc9534e89901f to your computer and use it in GitHub Desktop.
package org.zalando.nakadi.client.examples.java;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.zalando.nakadi.client.java.Client;
import org.zalando.nakadi.client.java.Listener;
import org.zalando.nakadi.client.java.StreamParameters;
import org.zalando.nakadi.client.java.model.Cursor;
import org.zalando.nakadi.client.java.model.EventStreamBatch;
import org.zalando.nakadi.client.scala.ClientFactory;
import com.fasterxml.jackson.core.type.TypeReference;
public class EventListenerExample {
/**
* Implement the Listener interface
*/
public static void main(String[] args) throws InterruptedException,
ExecutionException {
/**
* Create client
*/
final Client client = ClientFactory.getJavaClient();
/**
* Initialize our Listener
*/
Listener<MeetingsEvent> listener = new EventCounterListener("Java-Test");
StreamParameters params = new StreamParameters(Optional.of(new Cursor(
"0", "BEGIN")), Optional.of(1),// batchLimit,
Optional.empty(),// streamLimit,
Optional.empty(),// batchFlushTimeout,
Optional.empty(),// streamTimeout,
Optional.empty(),// streamKeepAliveLimit,
Optional.empty()// flowId
);
// String eventTypeName = "Example-unique-hundred-messages-3";
String eventTypeName = "Example-unique-million-messages";
TypeReference<EventStreamBatch<MeetingsEvent>> typeRef = new TypeReference<EventStreamBatch<MeetingsEvent>>() {
};
client.subscribe(eventTypeName, params, listener, typeRef);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment