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

data class DistributedServiceHandle : MessageRecipientGroup

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

LatencyCalculator

interface LatencyCalculator

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

MessageTransfer

class MessageTransfer

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

MockMessagingService

class 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.

PeerHandle

data class PeerHandle : SingleMessageRecipient

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

ServicePeerAllocationStrategy

sealed class 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.

Properties

endpointsExternal

val endpointsExternal: List<MockMessagingService>

Get a List of all the MockMessagingService endpoints

receivedMessages

val receivedMessages: Observable<MessageTransfer>

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

sentMessages

val sentMessages: Observable<MessageTransfer>

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

Functions

pumpSend

fun pumpSend(block: Boolean): MessageTransfer?

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

stop

fun stop(): Unit

Stop all nodes within the network and clear any buffered messages

Inherited Functions

toToken

open fun toToken(context: SerializeAsTokenContext): SingletonSerializationToken

Extension Functions

contextLogger

fun Any.contextLogger(): Logger

When called from a companion object, returns the logger for the enclosing class.