xoom-actors
xoom-actors copied to clipboard
Individual mailboxes cannot be created except via properties
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.
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
- Is this ^^^ the configuration that you are looking for?
- If not, what would be different and how would it work?
- We did discuss the need for
ManyToOneConcurrentArrayQueuePlugin
to support allocating one mailbox per actor that requests one for the typeManyToOneConcurrentArrayQueueMailbox
. I agree with this, and it will be provided later this week.- I think that this is what you actually need, and it will not be done via configuration. Looking back at the above linked test, note that even
ConcurrentQueueMailboxPluginConfiguration
offers no configuration that enables multiple actors to have their own instance ofConcurrentQueueMailbox
. Rather, it is the way thatConcurrentQueueMailboxPlugin
is implemented. - Note how
ConcurrentQueueMailboxPlugin
works when a mailbox is requested, including that the hash code is ignored:- https://github.com/vlingo/xoom-actors/blob/f66fa3b15e593f49de0c30df9c34c172fb4d9dbe/src/main/java/io/vlingo/xoom/actors/plugin/mailbox/concurrentqueue/ConcurrentQueueMailboxPlugin.java#L61
- https://github.com/vlingo/xoom-actors/blob/f66fa3b15e593f49de0c30df9c34c172fb4d9dbe/src/main/java/io/vlingo/xoom/actors/plugin/mailbox/concurrentqueue/ConcurrentQueueMailboxPlugin.java#L79
- Next note how
ManyToOneConcurrentArrayQueuePlugin
works when a mailbox is requested:- https://github.com/vlingo/xoom-actors/blob/f66fa3b15e593f49de0c30df9c34c172fb4d9dbe/src/main/java/io/vlingo/xoom/actors/plugin/mailbox/agronampscarrayqueue/ManyToOneConcurrentArrayQueuePlugin.java#L72
- https://github.com/vlingo/xoom-actors/blob/f66fa3b15e593f49de0c30df9c34c172fb4d9dbe/src/main/java/io/vlingo/xoom/actors/plugin/mailbox/agronampscarrayqueue/ManyToOneConcurrentArrayQueuePlugin.java#L77
- In the case of
ManyToOneConcurrentArrayQueuePlugin
, only actorAddress
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 theConcurrentQueueMailboxPlugin
.
- I think that this is what you actually need, and it will not be done via configuration. Looking back at the above linked test, note that even
- Are there other features that you mean to have fixed/implemented?
@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.