-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mqtt connector does not work with Akka Typed #1836
Comments
Sounds more like a bug report for the Akka team. akka-mqtt-streaming uses Akka Typed under the hood, so may be there's some incompatibility when going from typed to classic to typed... |
Thanks for pointing that out. Yes, I can reproduce it by using this sample code: import akka.actor.typed.ActorSystem
import akka.actor.typed.scaladsl.Behaviors
import akka.actor.typed.scaladsl.adapter._
object Bug2 extends App {
val system = ActorSystem(Behaviors.ignore, "TopLevel")
system.toUntyped.spawn(Behaviors.ignore, "Another")
} However I am hesitant about opening an issue to Akka team yet. I am learning Akka yet so I am not sure if this pattern is considered a good practice. We are trying to create new actor on a typed actor system bypassing guardian actor and typed API is designed to make it harder on purpose. I think intended way of implementing this is creating system actors: import akka.actor.typed.{ActorRef, ActorSystem}
import akka.actor.typed.scaladsl.Behaviors
import scala.util.Try
object Alternative extends App {
import scala.concurrent.duration._
val system = ActorSystem(Behaviors.ignore, "TopLevel")
import system.executionContext
system.systemActorOf(Behaviors.ignore, "Another")(10.seconds)
.onComplete { x: Try[ActorRef[Nothing]] => println(s"Actor created - $x") }
} So probably it's better to create alternative constructor for ActorMqtttClientSession, which accepts typed ActorMaterializer or Materializer + typed.ActorSystem pair and uses system actors API in that case. WDYT? |
I don't really know. Maybe it'd be useful to discuss this particular issue at https://discuss.lightbend.com/c/akka first. |
Thanks for starting the discussion in the forums. Now it is clear that @ytaras would you be willing to create a PR? |
I had a stab at this today. It is tricky as the typed system returns a future of actor ref. I’m not sure how you can convert that to just an actor ref as per untyped. Looking for inspiration. |
I'm sorry for late reply.
Please let me know preferred way of implementation and if you want me to work on a PR for this. |
I have attempted to fix this in #1848 which copies the adapter code from akka but does not wrap the resulting |
Created a ticket to fix this in akka/akka: akka/akka#27437 |
Versions used
Akka version: 2.5.23
Alpakka MQTT Streaming: 1.1.0
Expected Behavior
I am trying to use MQTT Streaming in a project which is built on top of Akka Typed API.
Actual Behavior
If I try to pass ActorSystem to ActorMqttSession, it fails with exception:
Reproducible Test Case
It boils down to following code:
The text was updated successfully, but these errors were encountered: