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 connFactory = new ConnectionFactory() | |
connFactory.setHost("rabbitmq") | |
val conn = system.actorOf( | |
Props(new ConnectionOwner(connFactory)), | |
name = "conn") | |
val client = ConnectionOwner.createActor( | |
conn, | |
Props(new RpcClient()), | |
5 second) |
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
def compute(calc:ActorRef) { | |
implicit val timeout: Timeout = 5 second | |
for (x <- 0 to 5) { | |
for (y <-0 to 5) { | |
(calc ? AddRequest(x, y)).onComplete { | |
case Right(AddResponse(sum)) => println("%d + %d = %d".format(x, y, sum)) | |
case Left(error) => println(error) | |
} | |
} |
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
case class AddRequest(x:Int, y:Int) | |
case class AddResponse(sum:Int) | |
class Calculator extends Actor { | |
protected def receive = { | |
case AddRequest(a, b) => sender ! AddResponse(a + b) | |
} | |
} |
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
package com.aphelia | |
import akka.actor.{Actor, ActorRef} | |
import akka.pattern.ask | |
import akka.serialization.Serializer | |
import amqp.Amqp.{Publish, Delivery} | |
import amqp.{RpcClient, RpcServer} | |
import amqp.RpcServer.ProcessResult | |
import com.rabbitmq.client.AMQP.BasicProperties | |
import akka.dispatch.{Future, Await} |
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
package com.github.sstone.amqp | |
import java.util.UUID | |
import akka.actor.{ActorLogging, Actor, ActorSystem, Props} | |
import com.github.sstone.amqp.Amqp._ | |
import com.github.sstone.amqp.RpcServer.{IProcessor, ProcessResult} | |
import com.rabbitmq.client.{AMQP, BasicProperties, ConnectionFactory} | |
import scala.concurrent.Future |
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
mvn scala:console | |
scala> import fr.acinq.bitcoin._ | |
import fr.acinq.bitcoin._ | |
scala> val random = new scala.util.Random | |
random: scala.util.Random = scala.util.Random@54d1608f | |
scala> val key:BinaryData = new Array[Byte](32) | |
key: fr.acinq.bitcoin.BinaryData = 0000000000000000000000000000000000000000000000000000000000000000 |
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
import akka.actor.{ActorLogging, Props, Actor, ActorSystem} | |
import com.github.sstone.amqp.Amqp._ | |
import com.github.sstone.amqp.{ChannelOwner, Consumer, Amqp, ConnectionOwner} | |
import com.rabbitmq.client.ConnectionFactory | |
import scala.concurrent.duration._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
object Bug60 extends App { | |
implicit val system = ActorSystem("mySystem") |
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
package com.github.sstone.amqp | |
import java.util.concurrent.TimeUnit | |
import akka.actor._ | |
import akka.routing.{ActorRefRoutee, RoundRobinRoutingLogic, Router} | |
import akka.util.Timeout | |
import com.github.sstone.amqp.Amqp._ | |
import com.rabbitmq.client.ConnectionFactory |
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
package com.github.sstone.amqp.bug55 | |
import akka.actor.{Actor, ActorLogging, ActorSystem, Props} | |
import com.github.sstone.amqp.Amqp._ | |
import com.github.sstone.amqp.{Amqp, ChannelOwner, ConnectionOwner} | |
import com.rabbitmq.client.{AMQP, ConnectionFactory} | |
import scala.concurrent.duration._ | |
object MyProducer extends App { |
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
package com.github.sstone.amqp | |
import akka.testkit.TestProbe | |
import com.github.sstone.amqp.Amqp._ | |
import com.rabbitmq.client.AMQP.BasicProperties | |
import org.junit.runner.RunWith | |
import org.scalatest.junit.JUnitRunner | |
import scala.collection.JavaConversions._ | |
import scala.concurrent.duration._ |