Skip to content
Tim Harper edited this page Aug 30, 2015 · 14 revisions

v1.0.0-RC1

Overview

  • com.spingo.op_rabbit.consumer._ was moved into com.spingo.op_rabbit._; update your imports, accordingly.
  • The method of instantiating Subscription has changed, substantially. Subscription is now completely stateless.
  • Casting Header values in the Handler DSL has changed, and supports optionalProperty.

Subscription changes

Before, subscriptions were declared and registered like this:

val subscription = new Subscription {
  // A qos of 3 will cause up to 3 concurrent messages to be processed at any given time.
  def config = channel(qos = 3) {
    consume(topic("such-message-queue", List("some-topic.#"))) {
      body(as[Person]) { person =>
        // do work; this body is executed in a separate thread, as provided by the implicit execution context
        ack()
      }
    }
  }
}

rabbitControl ! subscription

subscription.initialized.foreach { _ =>
  println("Initialized!")
  subscription.close()
}

Subscription had a close() method and a closed property. This is no more.

The above is rewritten as follows for v1.0.0-RC1:

val subscription = Subscription {
  // A qos of 3 will cause up to 3 concurrent messages to be processed at any given time.
  def config = channel(qos = 3) {
    consume(topic("such-message-queue", List("some-topic.#"))) {
      body(as[Person]) { person =>
        // do work; this body is executed in a separate thread, as provided by the implicit execution context
        ack()
      }
    }
  }
}

val subscriptionRef = subscription.register(rabbitControl)

subscriptionRef.initialized.foreach { _ =>
  println("Initialized!")
  subscriptionRef.close()
}

Casting header values

Before, HeaderValues were cast using as follows:

property(Header("x-retries")).as(typeOf[Int])

This did not work for optionalProperty; the old way no longer works and the new way is shorter:

property(Header("x-retries").as[Int])
optionalProperty(Header("x-retries").as[Int])
Clone this wiki locally