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).
Modifier and Type | Class and Description |
---|---|
static class |
InMemoryMessagingNetwork.Companion |
static class |
InMemoryMessagingNetwork.DistributedServiceHandle
A class which represents information about nodes offering the same distributed service on the
class InMemoryMessagingNetwork . |
static class |
InMemoryMessagingNetwork.MessageTransfer
A class which represents a message being transferred from sender to recipients, within the InMemoryMessageNetwork.
|
static class |
InMemoryMessagingNetwork.MockMessagingService
A class that provides an abstraction over the nodes' messaging service that also contains the ability to
receive messages from the queue for testing purposes.
|
static class |
InMemoryMessagingNetwork.PeerHandle
A class which represents information about an entity on the
class InMemoryMessagingNetwork . |
static class |
InMemoryMessagingNetwork.ServicePeerAllocationStrategy
How traffic is allocated in the case where multiple nodes share a single identity, which happens for notaries
in a cluster. You don't normally ever need to change this: it is mostly useful for testing notary implementations.
|
Modifier and Type | Field and Description |
---|---|
static InMemoryMessagingNetwork.Companion |
Companion |
Modifier and Type | Method and Description |
---|---|
java.util.List<net.corda.testing.node.InMemoryMessagingNetwork.MockMessagingService> |
getEndpointsExternal()
Get a List of all the
class InMemoryMessagingNetwork.MockMessagingService endpoints |
NonExistentClass |
getReceivedMessages()
A stream of (sender, message, recipients) triples containing messages once they have been received.
|
NonExistentClass |
getSentMessages()
A stream of (sender, message, recipients) triples containing messages once they have been sent by
InMemoryMessagingNetwork.pumpSend . |
InMemoryMessagingNetwork.MessageTransfer |
pumpSend(boolean block)
Send the next queued message to the requested recipient(s) within the network
|
void |
stop()
Stop all nodes within the network and clear any buffered messages
|
toToken
toToken
public static InMemoryMessagingNetwork.Companion Companion
public NonExistentClass getSentMessages()
A stream of (sender, message, recipients) triples containing messages once they have been sent by InMemoryMessagingNetwork.pumpSend
.
InMemoryMessagingNetwork.pumpSend
public NonExistentClass getReceivedMessages()
A stream of (sender, message, recipients) triples containing messages once they have been received.
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
public 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.