corda / net.corda.testing.node / InMemoryMessagingNetwork

InMemoryMessagingNetwork

@ThreadSafe class InMemoryMessagingNetwork : 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).

Parameters

servicePeerAllocationStrategy - defines the strategy to be used when determining which peer to send to in case a service is addressed.

Types

DistributedServiceHandle

A class which represents information about nodes offering the same distributed service on the InMemoryMessagingNetwork.

data class DistributedServiceHandle : MessageRecipientGroup

LatencyCalculator

Implement this interface in order to inject artificial latency between sender/recipient pairs.

interface LatencyCalculator

MessageTransfer

A class which represents a message being transferred from sender to recipients, within the InMemoryMessageNetwork.

class MessageTransfer

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.

class MockMessagingService

PeerHandle

A class which represents information about an entity on the InMemoryMessagingNetwork.

data class PeerHandle : SingleMessageRecipient

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.

sealed class ServicePeerAllocationStrategy

Properties

endpointsExternal

Get a List of all the MockMessagingService endpoints

val endpointsExternal: List<MockMessagingService>

receivedMessages

A stream of (sender, message, recipients) triples containing messages once they have been received.

val receivedMessages: Observable<MessageTransfer>

sentMessages

A stream of (sender, message, recipients) triples containing messages once they have been sent by pumpSend.

val sentMessages: Observable<MessageTransfer>

Functions

pumpSend

Send the next queued message to the requested recipient(s) within the network

fun pumpSend(block: Boolean): MessageTransfer?

stop

Stop all nodes within the network and clear any buffered messages

fun stop(): Unit