Package actors

Class Actors


  • public class Actors
    extends Object
    Class that deploys and spawns verticles. If an address is not provided, one is generated. You only need a ActorRef to interact with a verticle. When a verticle is deployed it's waiting for messages to be processed. When a verticle is spawn, it processes a message or does some stuff and after that it's undeployed automatically. It register codecs to work with the immutable and persistent Jsons from the library json-values
    • Constructor Detail

      • Actors

        public Actors​(io.vertx.core.Vertx vertx,
                      io.vertx.core.DeploymentOptions deploymentOptions)
        Creates a factory to deploy and spawn verticles
        Parameters:
        vertx - the vertx instance
        deploymentOptions - the default deployment options that will be used for deploying and spawing verticles if one is not provided
      • Actors

        public Actors​(io.vertx.core.Vertx vertx)
        Creates a factory to deploy and spawn verticles
        Parameters:
        vertx - the vertx instance
    • Method Detail

      • deploy

        public <I,​O> io.vertx.core.Future<ActorRef<I,​O>> deploy​(String address,
                                                                            Consumer<io.vertx.core.eventbus.Message<I>> consumer)
        It deploys a verticle that listen on the given address.
        Type Parameters:
        I - the type of the message sent to the verticle
        O - the type of the reply
        Parameters:
        address - the address of the verticle
        consumer - the consumer that will process the messages sent to the verticle
        Returns:
        an ActorRef wrapped in a future
      • deploy

        public <I,​O> io.vertx.core.Future<ActorRef<I,​O>> deploy​(Consumer<io.vertx.core.eventbus.Message<I>> consumer)
        It deploys a verticle
        Type Parameters:
        I - the type of the message sent to the verticle
        O - the type of the reply
        Parameters:
        consumer - the consumer that will process the messages sent to the verticle
        Returns:
        an ActorRef wrapped in a future
      • deploy

        public <I,​O> io.vertx.core.Future<ActorRef<I,​O>> deploy​(Consumer<io.vertx.core.eventbus.Message<I>> consumer,
                                                                            io.vertx.core.DeploymentOptions options)
        Type Parameters:
        I - the type of the message sent to the verticle
        O - the type of the reply
        Parameters:
        consumer - the consumer that will process the messages sent to the verticle
        options - options for configuring the verticle deployment
        Returns:
        an ActorRef wrapped in a future
      • deploy

        public <I,​O> io.vertx.core.Future<ActorRef<I,​O>> deploy​(String address,
                                                                            Consumer<io.vertx.core.eventbus.Message<I>> consumer,
                                                                            io.vertx.core.DeploymentOptions options)
        Type Parameters:
        I - the type of the message sent to the verticle
        O - the type of the reply
        Parameters:
        address - the address of the verticle
        consumer - the consumer that will process the messages sent to the verticle
        options - options for configuring the verticle deployment
        Returns:
        an ActorRef wrapped in a future
      • deploy

        public <I,​O> io.vertx.core.Future<ActorRef<I,​O>> deploy​(String address,
                                                                            Function<I,​O> fn,
                                                                            io.vertx.core.DeploymentOptions options)
        Type Parameters:
        I - the type of the message sent to the verticle
        O - the type of the reply
        Parameters:
        address - the address of the verticle
        fn - the function that takes a message of type I and produces an output of type O
        options - options for configuring the verticle deployment
        Returns:
        an ActorRef wrapped in a future
      • deploy

        public <I,​O> io.vertx.core.Future<ActorRef<I,​O>> deploy​(String address,
                                                                            Function<I,​O> fn)
        Type Parameters:
        I - the type of the message sent to the verticle
        O - the type of the reply
        Parameters:
        address - the address of the verticle
        fn - the function that takes the messages and produces an output
        Returns:
        an ActorRef wrapped in a future
      • deploy

        public <I,​O> io.vertx.core.Future<ActorRef<I,​O>> deploy​(Function<I,​O> fn)
        Type Parameters:
        I - the type of the message sent to the verticle
        O - the type of the reply
        Parameters:
        fn - the function that takes a message of type I and produces an output of type O
        Returns:
        an ActorRef wrapped in a future
      • spawn

        public <I,​O> Supplier<Function<I,​io.vertx.core.Future<O>>> spawn​(Consumer<io.vertx.core.eventbus.Message<I>> consumer)
        Type Parameters:
        I - the type of the message sent to the verticle
        O - the type of the reply
        Parameters:
        consumer - the consumer that will process the messages sent to the verticle
        Returns:
        an ActorRef wrapped in a future
      • spawn

        public <I,​O> Supplier<Function<I,​io.vertx.core.Future<O>>> spawn​(Consumer<io.vertx.core.eventbus.Message<I>> consumer,
                                                                                     io.vertx.core.DeploymentOptions options)
        Type Parameters:
        I - the type of the message sent to the verticle
        O - the type of the reply
        Parameters:
        consumer - the consumer that will process the messages sent to the verticle
        options - options for configuring the verticle deployment
        Returns:
        an ActorRef wrapped in a future
      • spawn

        public <I,​O> Supplier<Function<I,​io.vertx.core.Future<O>>> spawn​(Function<I,​O> fn,
                                                                                     io.vertx.core.DeploymentOptions options)
        Type Parameters:
        I - the type of the message sent to the verticle
        O - the type of the reply
        Parameters:
        fn - the function that takes a message of type I and produces an output of type O
        options - options for configuring the verticle deployment
        Returns:
        an ActorRef wrapped in a future
      • spawn

        public <I,​O> Supplier<Function<I,​io.vertx.core.Future<O>>> spawn​(Function<I,​O> fn)
        Type Parameters:
        I - the type of the input message
        O - the type of the output
        Parameters:
        fn - the function that takes a message of type I and produces an output of type O
        Returns:
        an ActorRef wrapped in a future