Skip to content

Instantly share code, notes, and snippets.

@sstone
Created August 21, 2012 19:25
Show Gist options
  • Save sstone/3418530 to your computer and use it in GitHub Desktop.
Save sstone/3418530 to your computer and use it in GitHub Desktop.
proxy server
val system = ActorSystem("MySystem")
val calc = system.actorOf(Props[Calculator])
val connFactory = new ConnectionFactory()
connFactory.setHost("localhost")
val conn = system.actorOf(
Props(new ConnectionOwner(connFactory)),
name = "conn")
val exchange = ExchangeParameters(name = "amq.direct", exchangeType = "", passive = true)
val queue = QueueParameters(name = "calculator", passive = false, autodelete = true)
val channelParams = Some(ChannelParameters(qos = 1))
// create an AMQP RPC server which consumes messages from queue "calculator"
// and passes them to our Calculator actor
val server = ConnectionOwner.createActor(
conn,
Props(
new RpcServer(
queue,
exchange,
"calculator",
new AmqpProxy.ProxyServer(calc, JsonSerializer),
channelParams
)
),
2 second)
waitForConnection(system, server).await()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment