@ThreadSafe public class InMemoryMessagingNetwork extends SingletonSerializeAsToken
An in-memory network allows you to manufacture MockNodeMessagingServices for a set of participants. Each MockNodeMessagingService maintains a queue of messages it has received, and a background thread that dispatches messages one by one to registered handlers. Alternatively, a messaging system may be manually pumped, in which case no thread is created and a caller is expected to force delivery one at a time (this is useful for unit testing).
public static net.corda.testing.node.InMemoryMessagingNetwork.Companion Companion
@NotNull public rx.Observable<net.corda.testing.node.InMemoryMessagingNetwork.MessageTransfer> getSentMessages()
A stream of (sender, message, recipients) triples containing messages once they have been sent by pumpSend
.
pumpSend
@NotNull public rx.Observable<net.corda.testing.node.InMemoryMessagingNetwork.MessageTransfer> getReceivedMessages()
A stream of (sender, message, recipients) triples containing messages once they have been received.
@Synchronized @NotNull public java.util.List<net.corda.testing.node.InMemoryMessagingNetwork.MockMessagingService> getEndpointsExternal()
Get a List of all the class InMemoryMessagingNetwork.MockMessagingService
endpoints
public void stop()
Stop all nodes within the network and clear any buffered messages
@Nullable public net.corda.testing.node.InMemoryMessagingNetwork.MessageTransfer pumpSend(boolean block)
Send the next queued message to the requested recipient(s) within the network
block
- If set to true this function will only return once a message has been pushed onto the recipients'queues. This is only relevant if a latencyCalculator is being used to simulate latency in the network.