io.vlingo.actors.LocalMessage Java Examples
The following examples show how to use
io.vlingo.actors.LocalMessage.
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: GridApplicationMessageHandler.java From vlingo-lattice with Mozilla Public License 2.0 | 6 votes |
@Override @SuppressWarnings({"rawtypes", "unchecked"}) public void visit(final Id receiver, final Id sender, final Relocate relocate) { final Id recipient = receiver(receiver, relocate.address); if (recipient == receiver) { final List<LocalMessage> pending = relocate.pending.stream() .map(deliver -> new LocalMessage(null, deliver.protocol, deliver.consumer, returnsAnswer(receiver, sender, deliver), deliver.representation)) .collect(Collectors.toCollection(ArrayList::new)); inbound.relocate(receiver, sender, relocate.definition, relocate.address, relocate.snapshot, pending); } else { outbound.forward(recipient, sender, relocate); } }
Example #3
Source File: Deliver.java From vlingo-lattice with Mozilla Public License 2.0 | 6 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) public static Function<io.vlingo.actors.Message, Deliver<?>> from(BiConsumer<UUID, Returns<?>> correlation) { return (message) -> { final LocalMessage<?> __message = (LocalMessage<?>) message; final Optional<Returns<?>> returns = Optional.ofNullable(__message.returns()); final UUID answerCorrelationId = returns.map(_return -> { final UUID correlationId = UUID.randomUUID(); correlation.accept(correlationId, _return); return correlationId; }).orElse(null); return new Deliver( __message.protocol(), __message.actor().address(), Definition.SerializationProxy.from(__message.actor().definition()), __message.consumer(), answerCorrelationId, __message.representation()); }; }
Example #4
Source File: Space__Proxy.java From vlingo-lattice with Mozilla Public License 2.0 | 5 votes |
@Override public <T>io.vlingo.common.Completes<T> itemFor(java.lang.Class<T> arg0, java.lang.Class<? extends io.vlingo.actors.Actor> arg1, java.lang.Object... arg2) { if (!actor.isStopped()) { ActorProxyBase<Space> self = this; final SerializableConsumer<Space> consumer = (actor) -> actor.itemFor(ActorProxyBase.thunk(self, (Actor)actor, arg0), ActorProxyBase.thunk(self, (Actor)actor, arg1), ActorProxyBase.thunk(self, (Actor)actor, arg2)); final io.vlingo.common.Completes<T> returnValue = Completes.using(actor.scheduler()); if (mailbox.isPreallocated()) { mailbox.send(actor, Space.class, consumer, Returns.value(returnValue), itemForRepresentation4); } else { mailbox.send(new LocalMessage<Space>(actor, Space.class, consumer, Returns.value(returnValue), itemForRepresentation4)); } return returnValue; } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, itemForRepresentation4)); } return null; }
Example #5
Source File: ObjectStoreWriterPersistResultInterest__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
@Override public void persistResultedIn(io.vlingo.common.Outcome<io.vlingo.symbio.store.StorageException, io.vlingo.symbio.store.Result> arg0, java.lang.Object arg1, int arg2, int arg3, java.lang.Object arg4) { if (!actor.isStopped()) { final SerializableConsumer<PersistResultInterest> consumer = (actor) -> actor.persistResultedIn(arg0, arg1, arg2, arg3, arg4); if (mailbox.isPreallocated()) { mailbox.send(actor, PersistResultInterest.class, consumer, null, persistResultedInRepresentation1); } else { mailbox.send(new LocalMessage<PersistResultInterest>(actor, PersistResultInterest.class, consumer, persistResultedInRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, persistResultedInRepresentation1)); } }
Example #6
Source File: ObjectStoreReaderQueryResultInterest__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
@Override public void queryAllResultedIn(io.vlingo.common.Outcome<io.vlingo.symbio.store.StorageException, io.vlingo.symbio.store.Result> arg0, io.vlingo.symbio.store.object.ObjectStoreReader.QueryMultiResults arg1, java.lang.Object arg2) { if (!actor.isStopped()) { final SerializableConsumer<QueryResultInterest> consumer = (actor) -> actor.queryAllResultedIn(arg0, arg1, arg2); if (mailbox.isPreallocated()) { mailbox.send(actor, QueryResultInterest.class, consumer, null, queryAllResultedInRepresentation1); } else { mailbox.send(new LocalMessage<QueryResultInterest>(actor, QueryResultInterest.class, consumer, queryAllResultedInRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, queryAllResultedInRepresentation1)); } }
Example #7
Source File: ObjectStoreReaderQueryResultInterest__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
@Override public void queryObjectResultedIn(io.vlingo.common.Outcome<io.vlingo.symbio.store.StorageException, io.vlingo.symbio.store.Result> arg0, io.vlingo.symbio.store.object.ObjectStoreReader.QuerySingleResult arg1, java.lang.Object arg2) { if (!actor.isStopped()) { final SerializableConsumer<QueryResultInterest> consumer = (actor) -> actor.queryObjectResultedIn(arg0, arg1, arg2); if (mailbox.isPreallocated()) { mailbox.send(actor, QueryResultInterest.class, consumer, null, queryObjectResultedInRepresentation2); } else { mailbox.send(new LocalMessage<QueryResultInterest>(actor, QueryResultInterest.class, consumer, queryObjectResultedInRepresentation2)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, queryObjectResultedInRepresentation2)); } }
Example #8
Source File: ObjectStore__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
@Override public Completes<EntryReader<? extends Entry<?>>> entryReader(final String arg0) { if (!actor.isStopped()) { final SerializableConsumer<ObjectStore> consumer = (actor) -> actor.entryReader(arg0); final Completes<EntryReader<? extends Entry<?>>> completes = new BasicCompletes<>(actor.scheduler()); if (mailbox.isPreallocated()) { mailbox.send(actor, ObjectStore.class, consumer, Returns.value(completes), entryReaderRepresentation2); } else { mailbox.send(new LocalMessage<ObjectStore>(actor, ObjectStore.class, consumer, Returns.value(completes), entryReaderRepresentation2)); } return completes; } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, entryReaderRepresentation2)); } return null; }
Example #9
Source File: ObjectStore__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
private void send(final String representation, final SerializableConsumer<ObjectStore> consumer) { if (!actor.isStopped()) { if (mailbox.isPreallocated()) { mailbox.send(actor, ObjectStore.class, consumer, null, representation); } else { mailbox.send(new LocalMessage<>(actor, ObjectStore.class, consumer, representation)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, representation)); } }
Example #10
Source File: ObjectStoreQueryResultInterest__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
@Override public void queryAllResultedIn(io.vlingo.common.Outcome<io.vlingo.symbio.store.StorageException, io.vlingo.symbio.store.Result> arg0, io.vlingo.symbio.store.object.ObjectStore.QueryMultiResults arg1, java.lang.Object arg2) { if (!actor.isStopped()) { final SerializableConsumer<QueryResultInterest> consumer = (actor) -> actor.queryAllResultedIn(arg0, arg1, arg2); if (mailbox.isPreallocated()) { mailbox.send(actor, QueryResultInterest.class, consumer, null, queryAllResultedInRepresentation1); } else { mailbox.send(new LocalMessage<QueryResultInterest>(actor, QueryResultInterest.class, consumer, queryAllResultedInRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, queryAllResultedInRepresentation1)); } }
Example #11
Source File: ObjectStoreQueryResultInterest__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
@Override public void queryObjectResultedIn(io.vlingo.common.Outcome<io.vlingo.symbio.store.StorageException, io.vlingo.symbio.store.Result> arg0, io.vlingo.symbio.store.object.ObjectStore.QuerySingleResult arg1, java.lang.Object arg2) { if (!actor.isStopped()) { final SerializableConsumer<QueryResultInterest> consumer = (actor) -> actor.queryObjectResultedIn(arg0, arg1, arg2); if (mailbox.isPreallocated()) { mailbox.send(actor, QueryResultInterest.class, consumer, null, queryObjectResultedInRepresentation2); } else { mailbox.send(new LocalMessage<QueryResultInterest>(actor, QueryResultInterest.class, consumer, queryObjectResultedInRepresentation2)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, queryObjectResultedInRepresentation2)); } }
Example #12
Source File: ObjectStorePersistResultInterest__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
@Override public void persistResultedIn(Outcome<StorageException, Result> arg0, java.lang.Object arg1, int arg2, int arg3, Object arg4) { if (!actor.isStopped()) { final SerializableConsumer<PersistResultInterest> consumer = (actor) -> actor.persistResultedIn(arg0, arg1, arg2, arg3, arg4); if (mailbox.isPreallocated()) { mailbox.send(actor, PersistResultInterest.class, consumer, null, persistResultedInRepresentation1); } else { mailbox.send(new LocalMessage<PersistResultInterest>(actor, PersistResultInterest.class, consumer, persistResultedInRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, persistResultedInRepresentation1)); } }
Example #13
Source File: ConfirmDispatchedResultInterest__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
public void confirmDispatchedResultedIn(io.vlingo.symbio.store.Result arg0, java.lang.String arg1) { if (!actor.isStopped()) { final SerializableConsumer<ConfirmDispatchedResultInterest> consumer = (actor) -> actor.confirmDispatchedResultedIn(arg0, arg1); if (mailbox.isPreallocated()) { mailbox.send(actor, ConfirmDispatchedResultInterest.class, consumer, null, confirmDispatchedResultedInRepresentation1); } else { mailbox.send(new LocalMessage<ConfirmDispatchedResultInterest>(actor, ConfirmDispatchedResultInterest.class, consumer, confirmDispatchedResultedInRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, confirmDispatchedResultedInRepresentation1)); } }
Example #14
Source File: Dispatcher__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
private void send(final SerializableConsumer<Dispatcher> consumer, final String representation) { if (!actor.isStopped()) { if (mailbox.isPreallocated()) { mailbox.send(actor, Dispatcher.class, consumer, null, representation); } else { mailbox.send(new LocalMessage<>(actor, Dispatcher.class, consumer, representation)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, representation)); } }
Example #15
Source File: DispatcherControl__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
private void send(final SerializableConsumer<DispatcherControl> consumer, final String representation) { if (!actor.isStopped()) { if (mailbox.isPreallocated()) { mailbox.send(actor, DispatcherControl.class, consumer, null, representation); } else { mailbox.send(new LocalMessage<>(actor, DispatcherControl.class, consumer, representation)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, representation)); } }
Example #16
Source File: Space__Proxy.java From vlingo-lattice with Mozilla Public License 2.0 | 5 votes |
@Override public <T>io.vlingo.common.Completes<java.util.Optional<io.vlingo.lattice.grid.spaces.KeyItem<T>>> get(io.vlingo.lattice.grid.spaces.Key arg0, io.vlingo.lattice.grid.spaces.Period arg1) { if (!actor.isStopped()) { ActorProxyBase<Space> self = this; final SerializableConsumer<Space> consumer = (actor) -> actor.get(ActorProxyBase.thunk(self, (Actor)actor, arg0), ActorProxyBase.thunk(self, (Actor)actor, arg1)); final io.vlingo.common.Completes<java.util.Optional<io.vlingo.lattice.grid.spaces.KeyItem<T>>> returnValue = Completes.using(actor.scheduler()); if (mailbox.isPreallocated()) { mailbox.send(actor, Space.class, consumer, Returns.value(returnValue), getRepresentation1); } else { mailbox.send(new LocalMessage<Space>(actor, Space.class, consumer, Returns.value(returnValue), getRepresentation1)); } return returnValue; } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, getRepresentation1)); } return null; }
Example #17
Source File: Space__Proxy.java From vlingo-lattice with Mozilla Public License 2.0 | 5 votes |
@Override public <T>io.vlingo.common.Completes<io.vlingo.lattice.grid.spaces.KeyItem<T>> put(io.vlingo.lattice.grid.spaces.Key arg0, io.vlingo.lattice.grid.spaces.Item<T> arg1) { if (!actor.isStopped()) { ActorProxyBase<Space> self = this; final SerializableConsumer<Space> consumer = (actor) -> actor.put(ActorProxyBase.thunk(self, (Actor)actor, arg0), ActorProxyBase.thunk(self, (Actor)actor, arg1)); final io.vlingo.common.Completes<io.vlingo.lattice.grid.spaces.KeyItem<T>> returnValue = Completes.using(actor.scheduler()); if (mailbox.isPreallocated()) { mailbox.send(actor, Space.class, consumer, Returns.value(returnValue), putRepresentation2); } else { mailbox.send(new LocalMessage<Space>(actor, Space.class, consumer, Returns.value(returnValue), putRepresentation2)); } return returnValue; } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, putRepresentation2)); } return null; }
Example #18
Source File: Space__Proxy.java From vlingo-lattice with Mozilla Public License 2.0 | 5 votes |
@Override public <T>io.vlingo.common.Completes<java.util.Optional<io.vlingo.lattice.grid.spaces.KeyItem<T>>> take(io.vlingo.lattice.grid.spaces.Key arg0, io.vlingo.lattice.grid.spaces.Period arg1) { if (!actor.isStopped()) { ActorProxyBase<Space> self = this; final SerializableConsumer<Space> consumer = (actor) -> actor.take(ActorProxyBase.thunk(self, (Actor)actor, arg0), ActorProxyBase.thunk(self, (Actor)actor, arg1)); final io.vlingo.common.Completes<java.util.Optional<io.vlingo.lattice.grid.spaces.KeyItem<T>>> returnValue = Completes.using(actor.scheduler()); if (mailbox.isPreallocated()) { mailbox.send(actor, Space.class, consumer, Returns.value(returnValue), takeRepresentation3); } else { mailbox.send(new LocalMessage<Space>(actor, Space.class, consumer, Returns.value(returnValue), takeRepresentation3)); } return returnValue; } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, takeRepresentation3)); } return null; }
Example #19
Source File: StateStore__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
@Override public Completes<Stream> streamSomeUsing(final QueryExpression query) { if (!actor.isStopped()) { final SerializableConsumer<StateStore> consumer = (actor) -> actor.streamSomeUsing(query); final Completes<Stream> completes = new BasicCompletes<>(actor.scheduler()); if (mailbox.isPreallocated()) { mailbox.send(actor, StateStore.class, consumer, Returns.value(completes), streamSomeUsingRepresentation5); } else { mailbox.send(new LocalMessage<StateStore>(actor, StateStore.class, consumer, Returns.value(completes), streamSomeUsingRepresentation5)); } return completes; } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, streamSomeUsingRepresentation5)); } return null; }
Example #20
Source File: Feeder__Proxy.java From vlingo-lattice with Mozilla Public License 2.0 | 5 votes |
@Override public void feedItemTo(io.vlingo.lattice.exchange.feed.FeedItemId arg0, io.vlingo.lattice.exchange.feed.FeedConsumer arg1) { if (!actor.isStopped()) { final SerializableConsumer<Feeder> consumer = (actor) -> actor.feedItemTo(arg0, arg1); if (mailbox.isPreallocated()) { mailbox.send(actor, Feeder.class, consumer, null, feedItemToRepresentation1); } else { mailbox.send(new LocalMessage<Feeder>(actor, Feeder.class, consumer, feedItemToRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, feedItemToRepresentation1)); } }
Example #21
Source File: ProjectionControl__Proxy.java From vlingo-lattice with Mozilla Public License 2.0 | 5 votes |
@Override public void confirmProjected(java.lang.String arg0) { if (!actor.isStopped()) { ActorProxyBase<ProjectionControl> self = this; final SerializableConsumer<ProjectionControl> consumer = (actor) -> actor.confirmProjected(ActorProxyBase.thunk(self, (Actor)actor, arg0)); if (mailbox.isPreallocated()) { mailbox.send(actor, ProjectionControl.class, consumer, null, confirmProjectedRepresentation1); } else { mailbox.send(new LocalMessage<ProjectionControl>(actor, ProjectionControl.class, consumer, confirmProjectedRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, confirmProjectedRepresentation1)); } }
Example #22
Source File: Projection__Proxy.java From vlingo-lattice with Mozilla Public License 2.0 | 5 votes |
public void projectWith(io.vlingo.lattice.model.projection.Projectable arg0, io.vlingo.lattice.model.projection.ProjectionControl arg1) { if (!actor.isStopped()) { final SerializableConsumer<Projection> consumer = (actor) -> actor.projectWith(arg0, arg1); if (mailbox.isPreallocated()) { mailbox.send(actor, Projection.class, consumer, null, projectWithRepresentation1); } else { mailbox.send(new LocalMessage<Projection>(actor, Projection.class, consumer, projectWithRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, projectWithRepresentation1)); } }
Example #23
Source File: ProjectionDispatcher__Proxy.java From vlingo-lattice with Mozilla Public License 2.0 | 5 votes |
public void projectTo(io.vlingo.lattice.model.projection.Projection arg0, java.lang.String[] arg1) { if (!actor.isStopped()) { final SerializableConsumer<ProjectionDispatcher> consumer = (actor) -> actor.projectTo(arg0, arg1); if (mailbox.isPreallocated()) { mailbox.send(actor, ProjectionDispatcher.class, consumer, null, projectToRepresentation1); } else { mailbox.send(new LocalMessage<ProjectionDispatcher>(actor, ProjectionDispatcher.class, consumer, projectToRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, projectToRepresentation1)); } }
Example #24
Source File: ResourceRequestHandler__Proxy.java From vlingo-http with Mozilla Public License 2.0 | 5 votes |
@Override @SuppressWarnings("rawtypes") public void handleFor(io.vlingo.http.Context arg0, java.util.function.Consumer arg1) { if (!actor.isStopped()) { final SerializableConsumer<ResourceRequestHandler> consumer = (actor) -> actor.handleFor(arg0, arg1); if (mailbox.isPreallocated()) { mailbox.send(actor, ResourceRequestHandler.class, consumer, null, handleForRepresentation1); } else { mailbox.send(new LocalMessage<ResourceRequestHandler>(actor, ResourceRequestHandler.class, consumer, handleForRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, handleForRepresentation1)); } }
Example #25
Source File: ResourceRequestHandler__Proxy.java From vlingo-http with Mozilla Public License 2.0 | 5 votes |
@Override public void handleFor(final Context arg0, final MappedParameters arg1, final RequestHandler arg2) { if (!actor.isStopped()) { final SerializableConsumer<ResourceRequestHandler> consumer = (actor) -> actor.handleFor(arg0, arg1, arg2); if (mailbox.isPreallocated()) { mailbox.send(actor, ResourceRequestHandler.class, consumer, null, handleForRepresentation2); } else { mailbox.send(new LocalMessage<ResourceRequestHandler>(actor, ResourceRequestHandler.class, consumer, handleForRepresentation2)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, handleForRepresentation2)); } }
Example #26
Source File: FeedProducer__Proxy.java From vlingo-http with Mozilla Public License 2.0 | 5 votes |
@Override public void produceFeedFor(io.vlingo.http.resource.feed.FeedProductRequest arg0) { if (!actor.isStopped()) { ActorProxyBase<FeedProducer> self = this; final SerializableConsumer<FeedProducer> consumer = (actor) -> actor.produceFeedFor(ActorProxyBase.thunk(self, (Actor)actor, arg0)); if (mailbox.isPreallocated()) { mailbox.send(actor, FeedProducer.class, consumer, null, produceFeedForRepresentation1); } else { mailbox.send(new LocalMessage<FeedProducer>(actor, FeedProducer.class, consumer, produceFeedForRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, produceFeedForRepresentation1)); } }
Example #27
Source File: SseFeed__Proxy.java From vlingo-http with Mozilla Public License 2.0 | 5 votes |
@Override public void to(java.util.Collection<io.vlingo.http.resource.sse.SseSubscriber> arg0) { if (!actor.isStopped()) { final SerializableConsumer<SseFeed> consumer = (actor) -> actor.to(arg0); if (mailbox.isPreallocated()) { mailbox.send(actor, SseFeed.class, consumer, null, toRepresentation1); } else { mailbox.send(new LocalMessage<SseFeed>(actor, SseFeed.class, consumer, toRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, toRepresentation1)); } }
Example #28
Source File: Scheduled__Proxy.java From vlingo-actors with Mozilla Public License 2.0 | 5 votes |
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public void intervalSignal(io.vlingo.common.Scheduled<T> arg0, T arg1) { if (!actor.isStopped()) { final SerializableConsumer<Scheduled> consumer = (actor) -> actor.intervalSignal(arg0, arg1); if (mailbox.isPreallocated()) { mailbox.send(actor, Scheduled.class, consumer, null, intervalSignalRepresentation1); } else { mailbox.send(new LocalMessage<Scheduled>(actor, Scheduled.class, consumer, intervalSignalRepresentation1)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, intervalSignalRepresentation1)); } }
Example #29
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 #30
Source File: StateStoreEntryReader__Proxy.java From vlingo-symbio with Mozilla Public License 2.0 | 5 votes |
@Override public void close() { if (!actor.isStopped()) { final SerializableConsumer<StateStoreEntryReader> consumer = (actor) -> actor.close(); if (mailbox.isPreallocated()) { mailbox.send(actor, StateStoreEntryReader.class, consumer, null, closeRepresentation3); } else { mailbox.send(new LocalMessage<StateStoreEntryReader>(actor, StateStoreEntryReader.class, consumer, closeRepresentation3)); } } else { actor.deadLetters().failedDelivery(new DeadLetter(actor, closeRepresentation3)); } }