io.vlingo.actors.Mailbox Java Examples
The following examples show how to use
io.vlingo.actors.Mailbox.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ManyToOneConcurrentArrayQueueDispatcherTest.java From vlingo-actors with Mozilla Public License 2.0 | 6 votes |
@Test public void testBasicDispatch() { final int mailboxSize = 64; final TestResults testResults = new TestResults(MailboxSize); final ManyToOneConcurrentArrayQueueDispatcher dispatcher = new ManyToOneConcurrentArrayQueueDispatcher(mailboxSize, 2, false, 4, 10); dispatcher.start(); final Mailbox mailbox = dispatcher.mailbox(); final CountTakerActor actor = new CountTakerActor(testResults); for (int count = 1; count <= mailboxSize; ++count) { final int countParam = count; final SerializableConsumer<CountTaker> consumer = (consumerActor) -> consumerActor.take(countParam); final LocalMessage<CountTaker> message = new LocalMessage<>(actor, CountTaker.class, consumer, "take(int)"); mailbox.send(message); } assertEquals(mailboxSize, testResults.getHighest()); }
Example #2
Source File: RingBufferDispatcherTest.java From vlingo-actors with Mozilla Public License 2.0 | 6 votes |
@Test public void testOverflowDispatch() throws Exception { final int mailboxSize = 64; final int overflowSize = mailboxSize * 2; final TestResults testResults = new TestResults(mailboxSize); final RingBufferDispatcher dispatcher = new RingBufferDispatcher(mailboxSize, 2, false, 4); final Mailbox mailbox = dispatcher.mailbox(); final CountTakerActor actor = new CountTakerActor(testResults); for (int count = 1; count <= overflowSize; ++count) { final int countParam = count; final SerializableConsumer<CountTaker> consumer = (consumerActor) -> consumerActor.take(countParam); mailbox.send(actor, CountTaker.class, consumer, null, "take(int)"); } dispatcher.start(); assertEquals(overflowSize, testResults.getHighest()); }
Example #3
Source File: ManyToOneConcurrentArrayQueueDispatcherTest.java From vlingo-actors with Mozilla Public License 2.0 | 5 votes |
@Test public void testNotifyOnSendDispatch() throws Exception { final int mailboxSize = 64; final TestResults testResults = new TestResults(mailboxSize); final ManyToOneConcurrentArrayQueueDispatcher dispatcher = new ManyToOneConcurrentArrayQueueDispatcher(mailboxSize, 1000, true, 4, 10); dispatcher.start(); final Mailbox mailbox = dispatcher.mailbox(); final CountTakerActor actor = new CountTakerActor(testResults); for (int count = 1; count <= mailboxSize; ++count) { final int countParam = count; final SerializableConsumer<CountTaker> consumer = (consumerActor) -> consumerActor.take(countParam); final LocalMessage<CountTaker> message = new LocalMessage<>(actor, CountTaker.class, consumer, "take(int)"); // notify if in back off mailbox.send(message); // every third message give time for dispatcher to back off if (count % 3 == 0) { Thread.sleep(50); } } assertEquals(mailboxSize, testResults.getHighest()); }
Example #4
Source File: RingBufferDispatcherTest.java From vlingo-actors with Mozilla Public License 2.0 | 5 votes |
@Test public void testNotifyOnSendDispatch() throws Exception { final int mailboxSize = 64; final TestResults testResults = new TestResults(mailboxSize); final RingBufferDispatcher dispatcher = new RingBufferDispatcher(mailboxSize, 1000, true, 4); dispatcher.start(); final Mailbox mailbox = dispatcher.mailbox(); final CountTakerActor actor = new CountTakerActor(testResults); for (int count = 1; count <= mailboxSize; ++count) { final int countParam = count; final SerializableConsumer<CountTaker> consumer = (consumerActor) -> consumerActor.take(countParam); // notify if in back off mailbox.send(actor, CountTaker.class, consumer, null, "take(int)"); // every third message give time for dispatcher to back off if (count % 3 == 0) { Thread.sleep(50); } } assertEquals(mailboxSize, testResults.getHighest()); }
Example #5
Source File: ConcurrentQueueMailboxPlugin.java From vlingo-actors with Mozilla Public License 2.0 | 5 votes |
@Override public Mailbox provideMailboxFor(final int hashCode, final Dispatcher dispatcher) { if (dispatcher == null) { throw new IllegalArgumentException("Dispatcher must not be null."); } return new ConcurrentQueueMailbox(dispatcher, configuration.dispatcherThrottlingCount()); }
Example #6
Source File: ManyToOneConcurrentArrayQueueMailbox.java From vlingo-actors with Mozilla Public License 2.0 | 5 votes |
@Override public void suspendExceptFor(final String name, final Class<?>... overrides) { // TODO: Consider supporting Stowage here if (!name.equals(Mailbox.Stopping)) { System.out.println("WARNING: ManyToOneConcurrentArrayQueueMailbox does not support suspendExceptFor(): " + name + " overrides: " + overrides); } }
Example #7
Source File: ManyToOneConcurrentArrayQueuePlugin.java From vlingo-actors with Mozilla Public License 2.0 | 5 votes |
@Override public Mailbox provideMailboxFor(final int hashCode, final Dispatcher dispatcher) { final ManyToOneConcurrentArrayQueueDispatcher maybeDispatcher = dispatcher != null ? (ManyToOneConcurrentArrayQueueDispatcher) dispatcher : dispatchers.get(hashCode); if (maybeDispatcher == null) { final ManyToOneConcurrentArrayQueueDispatcher newDispatcher = new ManyToOneConcurrentArrayQueueDispatcher( configuration.ringSize(), configuration.fixedBackoff(), configuration.notifyOnSend(), configuration.dispatcherThrottlingCount(), configuration.sendRetires()); final ManyToOneConcurrentArrayQueueDispatcher otherDispatcher = dispatchers.putIfAbsent(hashCode, newDispatcher); if (otherDispatcher != null) { otherDispatcher.start(); return otherDispatcher.mailbox(); } else { newDispatcher.start(); return newDispatcher.mailbox(); } } return maybeDispatcher.mailbox(); }
Example #8
Source File: SharedRingBufferMailboxPlugin.java From vlingo-actors with Mozilla Public License 2.0 | 5 votes |
@Override public Mailbox provideMailboxFor(final int hashCode, final Dispatcher dispatcher) { final RingBufferDispatcher maybeDispatcher = dispatcher != null ? (RingBufferDispatcher) dispatcher : dispatchers.get(hashCode); if (maybeDispatcher == null) { final RingBufferDispatcher newDispatcher = new RingBufferDispatcher( configuration.ringSize(), configuration.fixedBackoff(), configuration.notifyOnSend(), configuration.dispatcherThrottlingCount()); final RingBufferDispatcher otherDispatcher = dispatchers.putIfAbsent(hashCode, newDispatcher); if (otherDispatcher != null) { otherDispatcher.start(); return otherDispatcher.mailbox(); } else { newDispatcher.start(); return newDispatcher.mailbox(); } } return maybeDispatcher.mailbox(); }
Example #9
Source File: DefaultMailboxProviderKeeper.java From vlingo-actors with Mozilla Public License 2.0 | 5 votes |
public Mailbox assignMailbox(final String name, final int hashCode) { MailboxProviderInfo info = mailboxProviderInfos.get(name); if (info == null) { throw new IllegalStateException("No registered MailboxProvider named " + name); } return info.mailboxProvider.provideMailboxFor(hashCode); }
Example #10
Source File: ConcurrentQueueMailboxPlugin.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
@Override public Mailbox provideMailboxFor(final int hashCode) { return new ConcurrentQueueMailbox(executorDispatcher, configuration.dispatcherThrottlingCount()); }
Example #11
Source File: SseFeed__Proxy.java From vlingo-http with Mozilla Public License 2.0 | 4 votes |
public SseFeed__Proxy(final Actor actor, final Mailbox mailbox){ this.actor = actor; this.mailbox = mailbox; }
Example #12
Source File: ExecutorDispatcher.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
@Override public void execute(final Mailbox mailbox) { if (!closed.get()) { executor.execute(mailbox); } }
Example #13
Source File: RingBufferDispatcher.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
@Override public void execute(final Mailbox mailbox) { interrupt(); }
Example #14
Source File: RingBufferDispatcher.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
protected Mailbox mailbox() { return mailbox; }
Example #15
Source File: SharedRingBufferMailboxPlugin.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
@Override public Mailbox provideMailboxFor(final int hashCode) { return provideMailboxFor(hashCode, null); }
Example #16
Source File: ManyToOneConcurrentArrayQueuePlugin.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
@Override public Mailbox provideMailboxFor(final int hashCode) { return provideMailboxFor(hashCode, null); }
Example #17
Source File: ManyToOneConcurrentArrayQueueDispatcher.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
@Override public void execute(final Mailbox mailbox) { interrupt(); }
Example #18
Source File: ManyToOneConcurrentArrayQueueDispatcher.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
protected Mailbox mailbox() { return mailbox; }
Example #19
Source File: TestMailboxPlugin.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
@Override public Mailbox provideMailboxFor(final int hashCode) { return new TestMailbox(); }
Example #20
Source File: TestMailboxPlugin.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
@Override public Mailbox provideMailboxFor(final int hashCode, final Dispatcher dispatcher) { return new TestMailbox(); }
Example #21
Source File: Scheduled__Proxy.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
public Scheduled__Proxy(final Actor actor, final Mailbox mailbox){ this.actor = actor; this.mailbox = mailbox; }
Example #22
Source File: RingBufferDispatcherTest.java From vlingo-actors with Mozilla Public License 2.0 | 4 votes |
@Test public void testBasicDispatch() throws Exception { final int mailboxSize = 64; final TestResults testResults = new TestResults(mailboxSize); final RingBufferDispatcher dispatcher = new RingBufferDispatcher(mailboxSize, 2, false, 4); dispatcher.start(); final Mailbox mailbox = dispatcher.mailbox(); final CountTakerActor actor = new CountTakerActor(testResults); for (int count = 1; count <= mailboxSize; ++count) { final int countParam = count; final SerializableConsumer<CountTaker> consumer = (consumerActor) -> consumerActor.take(countParam); mailbox.send(actor, CountTaker.class, consumer, null, "take(int)"); } assertEquals(mailboxSize, testResults.getHighest()); }
Example #23
Source File: ConfirmDispatchedResultInterest__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 4 votes |
public ConfirmDispatchedResultInterest__Proxy(final Actor actor, final Mailbox mailbox){ this.actor = actor; this.mailbox = mailbox; }
Example #24
Source File: JournalReader__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 4 votes |
public JournalReader__Proxy(final Actor actor, final Mailbox mailbox){ this.actor = actor; this.mailbox = mailbox; }
Example #25
Source File: StateStoreWriteResultInterest__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 4 votes |
public StateStoreWriteResultInterest__Proxy(final Actor actor, final Mailbox mailbox){ this.actor = actor; this.mailbox = mailbox; }
Example #26
Source File: StateStoreEntryReader__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 4 votes |
public StateStoreEntryReader__Proxy(final Actor actor, final Mailbox mailbox){ this.actor = actor; this.mailbox = mailbox; }
Example #27
Source File: StateStoreReadResultInterest__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 4 votes |
public StateStoreReadResultInterest__Proxy(final Actor actor, final Mailbox mailbox){ this.actor = actor; this.mailbox = mailbox; }
Example #28
Source File: StateStore__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 4 votes |
public StateStore__Proxy(final Actor actor, final Mailbox mailbox){ this.actor = actor; this.mailbox = mailbox; }
Example #29
Source File: ObjectStoreWriterPersistResultInterest__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 4 votes |
public ObjectStoreWriterPersistResultInterest__Proxy(final Actor actor, final Mailbox mailbox){ this.actor = actor; this.mailbox = mailbox; }
Example #30
Source File: ObjectStoreReaderQueryResultInterest__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 4 votes |
public ObjectStoreReaderQueryResultInterest__Proxy(final Actor actor, final Mailbox mailbox){ this.actor = actor; this.mailbox = mailbox; }