vlingo / xoom-actors

The VLINGO XOOM platform SDK for the type-safe Actor Model, delivering Reactive concurrency, high scalability, high-throughput, and resiliency using Java and other JVM languages.
https://vlingo.io
Mozilla Public License 2.0
229 stars 28 forks source link

Individual mailboxes cannot be created except via properties #99

Open bwehrle opened 2 years ago

bwehrle commented 2 years ago

Therefore there is no way to create configurations programatically when different plugin configurations are needed. The most relevant case for this is that of the ManyToOneConcurrentArrayQueuePlugin. This mailbox type requires that there only be 1 mailbox per actor (it is M:1). See https://docs.vlingo.io/xoom-actors#mailbox - scroll to "arrayQueueMailbox" section.

As discussed with @VaughnVernon the existing system for mailbox configuration is limited to creating a single mailbox with a single given name. In the Configuration class, there is a configurationOverrides (Map<String, PluginConfiguration>). There is only one Plugin Configuration allowed per Plugin.

A better solution might include a plugin that creates a new mailbox dynamically for each actor that requests one; instead of specifying the mailbox name, the actor instantiation can request a mailbox configuration name, and an actual mailbox with this configuration can either be created or re-used, depending on the plugin configuration.

VaughnVernon commented 2 years ago

Hi @bwehrle We can code configure all mailbox plugins. Please see:

https://github.com/vlingo/xoom-actors/blob/f66fa3b15e593f49de0c30df9c34c172fb4d9dbe/src/test/java/io/vlingo/xoom/actors/ConfigurationTest.java#L50

VaughnVernon commented 2 years ago

@bwehrle Per this Slack message from @pflueras, would you please provide clarification on your request?

99 - I think he wants the configurations along with referenced plugins to be created 'on demand' instead of the current 'eager' creation from the startup:

the actor instantiation can request a mailbox configuration name

Neither one of us understands how you intend for this this to be used. Can you please provide a concrete use case?

VaughnVernon commented 2 years ago

@bwehrle Would you please ^^^ comment on the previous two comments, or at least the last one? We don't understand how you intend to use dynamic, in-code configuration.

VaughnVernon commented 2 years ago

@bwehrle Additionally I just implemented the single "arrayQueue" mailbox per actor instance. If a developer needs a kind of "shared mailbox" they can use one of the following router types:

io.vlingo.xoom.actors.BroadcastRouter<P>
io.vlingo.xoom.actors.ContentBasedRouter<P>
io.vlingo.xoom.actors.RandomRouter<P>
io.vlingo.xoom.actors.RoundRobinRouter<P>
io.vlingo.xoom.actors.SmallestMailboxRouter<P>

The implementation is in the current SNAPSHOT.

bwehrle commented 2 years ago

Sorry for falling behind on the threads here:

The problem with using the code configuration is that when I filed the issue the API for creating a ManyToOne mailbox did not allow the name to be specified. This was only available from properties. In addition, writing N properties is not a solution for dynamic number of actors.

I think that only leaves one options: define a type of mailbox and the properties that configure it

Let me paraphrase this with some pseudo code to make it really clear.

a = stage.createMeAnActor(actorType, MailboxSpec.from(ManyToOneMailbox.class, configProperties)) ...

Again, sorry for running behind: please ping me in gitter if I don't respond on an issue.

VaughnVernon commented 2 years ago

The API has always supported creating an actor with a mailbox by name. You used it in your overflow test:

    final CountTaker countTaker =
            world.actorFor(
                    CountTaker.class,
                    Definition.has(CountTakerActor.class,
                            Definition.parameters(testResults),
                            "testArrayQueueMailbox",
                            "countTaker-2"));

Notice: Definition.has(..., "testArrayQueueMailbox", ...) and the setUp():

Properties properties = new Properties();
properties.setProperty("plugin.name.testArrayQueueMailbox", "true");
. . .
ManyToOneConcurrentArrayQueuePlugin manyToOneConcurrentArrayQueuePlugin =
 new ManyToOneConcurrentArrayQueuePlugin();

PluginProperties pluginProperties =
  new PluginProperties("testArrayQueueMailbox", properties);
. . .
manyToOneConcurrentArrayQueuePlugin.configuration().buildWith(
      world.configuration(), pluginProperties);

manyToOneConcurrentArrayQueuePlugin.start(world);

Do any of these address what you are looking for? If we are missing any Stage::actorFor(...) implementation that you need it can certainly be added.