Open bwehrle opened 2 years ago
Hi @bwehrle We can code configure all mailbox plugins. Please see:
ManyToOneConcurrentArrayQueuePlugin
to support allocating one mailbox per actor that requests one for the type ManyToOneConcurrentArrayQueueMailbox
. I agree with this, and it will be provided later this week.
ConcurrentQueueMailboxPluginConfiguration
offers no configuration that enables multiple actors to have their own instance of ConcurrentQueueMailbox
. Rather, it is the way that ConcurrentQueueMailboxPlugin
is implemented.ConcurrentQueueMailboxPlugin
works when a mailbox is requested, including that the hash code is ignored:ManyToOneConcurrentArrayQueuePlugin
works when a mailbox is requested:ManyToOneConcurrentArrayQueuePlugin
, only actor Address
instances that have different hash codes will have different mailbox dispatchers. (I am not sure why this is the case, actually; seems close to unique, but not exactly.) Although the hash code is likely to be unique for individual actors, it is not guaranteed. The implementation should be simplified in a way very similar to that of the ConcurrentQueueMailboxPlugin
.@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?
@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.
@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.
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.
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.
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.