Created
July 27, 2015 15:38
-
-
Save timcharper/7388cf7f35bb7c9ce968 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// psuedo-code; will not actually compile | |
import com.spingo.op_rabbit.Json4sSupport._ // allows you to use Json4s directly to serialize / deserialize published messages | |
trait MarketOrEv | |
case class Market(mkt_id: Int, ev_id: Int, model_type:”Market”) extends MarketOrEv | |
case class Ev(ev_id: Int, model_type:”Ev”) extends MarketOrEv | |
implicit val formats = new Formats( | |
override val typeHints = ShortTypeHints(classOf[Market] :: classOf[Ev] :: Nil) | |
override val typeHintFieldName = "model_type" | |
) | |
val subscription = new Subscription { | |
def config = channel(qos = 3) { | |
consume(queue(name)) { | |
body(as[MarketOrEv]) { | |
case m: Market => | |
// do your thing... | |
ack | |
case e: Ev => | |
// do your thing... | |
ack | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment