Skip to content

Instantly share code, notes, and snippets.

@patriknw
patriknw / Squarer.java
Created December 14, 2019 08:47
Methods delegation to actor
package squerer;
import akka.actor.typed.ActorRef;
import akka.actor.typed.Behavior;
import akka.actor.typed.Scheduler;
import akka.actor.typed.javadsl.AbstractBehavior;
import akka.actor.typed.javadsl.ActorContext;
import akka.actor.typed.javadsl.AskPattern;
import akka.actor.typed.javadsl.Behaviors;
import akka.actor.typed.javadsl.Receive;
@patriknw
patriknw / AtLeastOnceExample.scala
Created September 11, 2019 06:52
AtLeastOnceDelivery in Akka Typed
package docs.akka.persistence.typed
import scala.concurrent.duration.FiniteDuration
import akka.actor.typed.ActorRef
import akka.actor.typed.Behavior
import akka.actor.typed.scaladsl.Behaviors
import akka.actor.typed.scaladsl.LoggerOps
import akka.persistence.typed.PersistenceId
import akka.persistence.typed.RecoveryCompleted
import akka.actor.testkit.typed.scaladsl.BehaviorTestKit
import akka.actor.typed.Behavior
import akka.actor.typed.scaladsl.AbstractBehavior
import org.scalatest.Matchers
import org.scalatest.WordSpec
object SyncTestingFSMExampleSpec {
sealed trait Command
final case class Type(c: Char) extends Command
@patriknw
patriknw / LinearStageLogic.scala
Created June 13, 2018 15:22
Prototype LinearStage
/**
* Copyright (C) 2018 Lightbend Inc. <http://www.lightbend.com>
*/
package akka.stream.stage
import scala.collection.immutable
import scala.concurrent.duration.FiniteDuration
import akka.NotUsed
import akka.annotation.InternalApi
@patriknw
patriknw / AccountExample1.scala
Last active May 23, 2018 09:51
Alternative implementation of PR 25051
object AccountExample1 {
sealed trait AccountCommand
case object CreateAccount extends AccountCommand
case class Deposit(amount: Double) extends AccountCommand
case class Withdraw(amount: Double) extends AccountCommand
case object CloseAccount extends AccountCommand
sealed trait AccountEvent
case object AccountCreated extends AccountEvent
@patriknw
patriknw / FlowControlSample.scala
Last active May 10, 2018 18:35
Illustrates Actor message flow control with "work pulling pattern". This code is licensed under the Apache 2 license.
package flowcontrol
import scala.concurrent.duration._
import akka.actor.typed.ActorRef
import akka.actor.typed.ActorSystem
import akka.actor.typed.Behavior
import akka.actor.typed.scaladsl.Behaviors
/**

Three nodes: gw-1001, gw-2001, gw-3001 At first everything is good, but after a while it Looks like some messages are not received. 1001 receives ok from 3001, but not from 2001 2001 receives ok from 3001, but not from 1001 3001 receives nothing from 1001 and 2001

Here are Aeron counters from the 3 nodes at 5 points in time. Note the NAKs.

  • gw-1001
@patriknw
patriknw / akka-getting-started-guide.txt
Created August 18, 2017 14:34
Getting Started Guide in plain text format
Akka Documentation - Getting Started Guide
------------------------------------------
Version 2.5.4
Also in HTML format:
http://doc.akka.io/docs/akka/current/scala/guide/index.html
http://doc.akka.io/docs/akka/current/java/guide/index.html
© 2011-2017 Lightbend
@patriknw
patriknw / AlpakkaPR.scala
Created April 18, 2017 15:21
Alpakka PR assignments
val reviewers = Vector(
"2m",
"jrudolph",
"johanandren",
"ktoso",
"patriknw",
"raboof"
)
def assign(pr: Int): String =
---
core/src/main/scala/akka/kafka/javadsl/Producer.scala | 12 ++++++------
core/src/main/scala/akka/kafka/scaladsl/Producer.scala | 18 +++++++++---------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/core/src/main/scala/akka/kafka/javadsl/Producer.scala b/core/src/main/scala/akka/kafka/javadsl/Producer.scala
index 86005b7..6bae123 100644
--- a/core/src/main/scala/akka/kafka/javadsl/Producer.scala
+++ b/core/src/main/scala/akka/kafka/javadsl/Producer.scala
@@ -38,11 +38,11 @@ object Producer {