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._ |
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.actor.{Props, Actor, ActorSystem} | |
import com.rabbitmq.client.ConnectionFactory | |
import com.github.sstone.amqp.Amqp.{Publish, AddStatusListener} | |
import com.github.sstone.amqp.ChannelOwner.{Disconnected, Connected} | |
import scala.concurrent.duration._ | |
object StatusListeners extends App { | |
import scala.concurrent.ExecutionContext.Implicits.global |
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.actor.ActorDSL._ | |
import akka.actor.{Props, Actor, ActorSystem} | |
import com.github.sstone.amqp.Amqp._ | |
import com.github.sstone.amqp.ChannelOwner.Connected | |
import com.rabbitmq.client.ConnectionFactory | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.duration._ |
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)) |
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) | |
} | |
} |