Created
August 21, 2012 19:25
-
-
Save sstone/3418530 to your computer and use it in GitHub Desktop.
proxy server
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
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