Skip to content

Register the listener in Scala

Fernando Benjamin edited this page Mar 22, 2017 · 7 revisions
 /**
   * Initialize our Listener
   */
  val listener = new EventCounterListener("Test")

  /**
   * Create the Parameters with the cursor.
   */

  val cursor = Cursor("0", "153000")
  val parameters = new StreamParameters( cursor=Some(cursor), //
                   batchLimit = Some(200),//
                   streamTimeout = Some(0))

  /**
   * Create TypeReference for the JacksonObjectMapper
   */

  implicit def typeRef: TypeReference[EventStreamBatch[MeetingsEvent]] = new TypeReference[EventStreamBatch[MeetingsEvent]] {}
  import org.zalando.nakadi.client.scala.model.ScalaJacksonJsonMarshaller._

  val eventTypeName = "MeetingsEvent-example-E"
  val result = client.subscribe(eventTypeName, parameters, listener)