Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 20:42
    treefolk edited #28162
  • 20:21
    akka-ci commented #28162
  • 20:19
    lightbend-cla-validator commented #28162
  • 20:19
    treefolk opened #28162
  • 19:43
  • 17:47
    johanandren commented #28161
  • 17:46
    johanandren commented #28161
  • 16:45
    helena unlabeled #26624
  • 11:40
    genzov starred akka/akka
  • 11:30
    patriknw commented #27751
  • 11:30
    patriknw closed #27751
  • 10:21
    raboof commented #28159
  • 09:37
    akka-ci commented #28152
  • 09:37
    akka-ci unlabeled #28152
  • 09:37
    akka-ci labeled #28152
  • 09:11
    akka-ci unlabeled #28152
  • 09:11
    akka-ci labeled #28152
  • 09:07
    chbatey synchronize #28152
  • 09:07

    chbatey on issue-28149

    Review feedback (compare)

Nathaniel Fischer
@kag0
Does anyone have a recommendation for a tutorial or class that covers use of sharding and persistence in a realistic example application?
lekan
@horlahlekhon

Hi, am new to the akka universe and i have been loving it... but i saw this way of creating an actor or maybe its not even creating an actor and i dont understand what is happening at all.

trait WithHttpProcessing {
  actor: Actor =>

  def httpClient: ActorRef

  def send(req: HttpRequest, data: Data): Unit =
    httpClient ! req -> data
  }

what will happen when i extend this trait and what does the actor: Actor => means. an explanation will really help. thanks much

Sean Kwak
@cosmir17
Can I ask when akka 2.6.0 version becomes available in Maven repository?
Tim Moore
@TimMoore
@horlahlekhon that's a Scala feature called "self types" https://docs.scala-lang.org/tour/self-types.html
lekan
@horlahlekhon
thanks.. i got it now
Sean Kwak
@cosmir17
OlafurD
@OlafurD

Hi guys

I'm trying to create an EventSourcedBehavior that contains N persistent child actors, but it should only spawn a child actor if it receives a command for a specific child actor, so only a subset of the child actors should be active at any given time.

I was thinking about adding a list of spawned child actors to the state of the parent actor, but I don't want to update the state of spawned child actors in the eventHandler, I'd like to update that state ad-hoc in the command handler. So for any command C targeting child actor d, I'd like to check if d has already been spawned, and forward the message to d. If it has not been spawned I want to spawn it and update the state with it

So I guess the question is, can I somehow update the state outside of the eventHandler, or can akka take an actorRef[T] and spawn it if it hasn't been spawned, otherwise forward to it?

Odd Möller
@odd
@OlafurD What about ctx.child(childName).getOrElse(ctx.spawn(childBehavior, childName)) (where ctx: ActorContext[...])?
Arnout Engelen
@raboof
@cosmir17 mvnrepository.com is a 3rd-party index that lags behind maven central itself, see e.g. https://stackoverflow.com/questions/44114621/library-on-maven2-central-repository-but-not-on-mvnrepository-com
Katrix
@Katrix
Is there a sink similar to Sink.actorRef, but which considers the death of the actor as the completion signal, and not some abnormal event?
Tim Moore
@TimMoore
@cosmir17 I assume that site scrapes Maven Central periodically
Daniel Gordon
@DanielGGordon
Is there an Akka for HTTP or just this one?

So I am trying to use akka http. Was using my own endpoint, but not working. So I just decided to copy/paste the simple example from the documentation:

    implicit val system = ActorSystem()
    implicit val materializer = ActorMaterializer()
    // needed for the future flatMap/onComplete in the end
    implicit val executionContext = system.dispatcher

    val responseFuture: Future[HttpResponse] = Http().singleRequest(HttpRequest(uri = "http://akka.io"))

    responseFuture
      .onComplete {
        case Success(res) => println(res)
        case Failure(_)   => println("something wrong")
      }

But guess what, it doesn't do anything.

And for the life of me I cannot figure it out
Tim Moore
@TimMoore
@DanielGGordon make sure you wait for the future to complete before the program exits. That example doesn't do it... I'll report that as a documentation bug.
Daniel Gordon
@DanielGGordon
Maybe I don't understand Futures well enough
So if I put a wait before .onComplete
Response entity was not subscribed after 1 second. Make sure to read the response entity body or calldiscardBytes()on it. GET / Empty -> 301 Moved Permanently Chunked
Tim Moore
@TimMoore
Not before... on the last line, Await.ready(responseFuture)
Tim Moore
@TimMoore
Now that I try running it myself, I can see there are a few problems with that example actually.
Daniel Gordon
@DanielGGordon
Await.ready(responseFuture, 10.seconds) aha so that is key there. Putting that before the call to .onComplete
Tim Moore
@TimMoore
It doesn't need to be before the call to onComplete... and now that I try it, I'm not sure it's actually requried at all, because the app doesn't shut down while the ActorSystem is running, and nothing ever stops it.
However, it doesn't follow the redirect from http → https, and it never reads the response, which is why you see that warning about the response being discarded
Tim Moore
@TimMoore
@DanielGGordon try this:
    val responseFuture: Future[Terminated] =
      Http()
        .singleRequest(HttpRequest(uri = "https://akka.io"))
        .flatMap(res => res.entity.toStrict(5.seconds))
        .andThen {
          case Success(entity) => println(entity)
          case Failure(e) => println("something went wrong: " + e)
        }
        .flatMap(_ => Http().shutdownAllConnectionPools())
        .flatMap(_ => system.terminate())

    Await.ready(responseFuture, 60.seconds)
Sean Kwak
@cosmir17
@raboof @TimMoore Thank you for your kind explanation ❤️
Tim Moore
@TimMoore
@DanielGGordon raised akka/akka-http#2805
Daniel Gordon
@DanielGGordon
@TimMoore I haven't had a chance but I will look at your snippet and thanks for the ticket!
lekan
@horlahlekhon

hi, can someone please explain; i saw someone today handling actor messages with functions that return the partial function Receive instead of the messages being a class or an object and using pattern matching to evaluate them as i only understand.. i.e

override def receive: Receive =
  handleMessage
  .orElse(handleMessageLikeAboss)
  .orElse(handleMessageLikeASlave)
  .orElse(handleHowever)

def handleMessage: Receive = ???

def handleMessageLikeAboss: Receive = ???

def handleMessageLikeASlave: Receive = ???

def handleHowever: Receive = ???

how are the cases evaluated, am confused. Thanks.

Aditya Sule
@adityagnet
I have a question about Killswitches and async graphs. Will KillSwitch.shutdown shut down the entire graph?
lekan
@horlahlekhon
@adityagnet yes, it will shutdown the whole graph, however if you want to only control only one materialized graph you can use KillSwitches.single.
Aditya Sule
@adityagnet
@horlahlekhon just to clarify since I'm a confused soul. Does it matter where in the flow you put the KillSwitch?
lekan
@horlahlekhon
am not sure of where it should come. but i think it should be before your sink, and surely before you call run*()
Daniel Gordon
@DanielGGordon
@TimMoore actually confused a little bit because what I need to do is parse the response and save some data. In your example I can't return anything from the .andThen.
Tim Moore
@TimMoore
@DanielGGordon OK well I was just updating the example, but you'll need to modify it for your use case. The Scala Future API has a lot of ways to use it. If you're not familiar at all, this is a good starting point https://docs.scala-lang.org/overviews/core/futures.html
Sean Kwak
@cosmir17

Hi, https://doc.akka.io/docs/akka/current/distributed-data.html#maps
there, I have found the following line.
val m1 = m0 :+ ("a" -> Set(1, 2, 3))

let say, my OrMultiMap has "e" key and it has Set(1,2,3)
what would happen, if I do the following operation?
val m2 = m1 :+ ("e" -> Set(2, 3, 5))
Will my OrMultiMap have Set(2,3,5) for "e" key OR Set(1,2,3,5)?
I think it's going to be the first as I saw that :+ does put.

finlaydotb
@finlaydotb
Hi all...quick question....is it possible to have Akka cluster run with Graal (instead of JVM) is this possible? Has this been done? or it is impossible?
Justin Reeves
@justinallenreeves
How do you handle Option in a Source? Don't I guess?
Justin Reeves
@justinallenreeves
  private val source: Source[StockQuote, NotUsed] = {
    StockQuoteService.quote(symbol) match {
      case Some(quote) =>  Source.single(quote)
      case None => log.error("No StockQuote to source")
    }
  }
Mäx K.
@maexrakete
hey everyone! pretty nooby question, but how can execute a substream conditionally and returning its value? Like
    val source: Source[Option[String], NotUsed] = ???
    val default: Source[String, NotUsed] = ???
    val result: Source[String, NotUsed] = source.map(_.getOrElse(default))
Nathaniel Fischer
@kag0
@maexrakete source.flatMapConcat(_.map(Source.single).getOrElse(default))
Mäx K.
@maexrakete
@kag0 Thanks! I found a workaround, but that one is really ugly, I'll try yours!
Ángel Cervera Claudio
@angelcervera
Hi all.
I'm migrating to AKKA Typed 2.6. I have a unit test testing the recovery. I use akka.actor.Kill and akka.actor.PoisonKill to destroy the actor depending of the case to test. Both are gone in AKKA Typed. How to do the same in AKKA Typed?
I asked the same in Stackoverflow but nobody reponse: https://stackoverflow.com/questions/58773176/testing-akka-2-6-persistence-actor-typed
Patrik Nordwall
@patriknw
PoisonPill replacement would be an application specific message that the actor understands and returns Behaviors.stopped. Alternatively the ActorTestKit has a stop method.
Kill is for simulating that the actor thows an exception. Same there, trigger a real error condition instead or add your own message and throw. Can also be done with a BehaviorInterceptor that you only add in tests.
where does system.scheduler() come from?
I'm also having issues with the type, replyTo is ActorRef<Res> while the actual behavior is ActorRef<Reply>?
Srepfler Srdan
@schrepfler
which I think can be fixed by passing the type params to ask explicitly AskPattern.<Command,Reply>ask