com.r3corda.node.services.network / InMemoryMessagingNetwork

InMemoryMessagingNetwork

class InMemoryMessagingNetwork : SingletonSerializeAsToken

An in-memory network allows you to manufacture InMemoryMessagings for a set of participants. Each InMemoryMessaging 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).



Types

Builder inner class Builder : MessagingServiceBuilder<InMemoryMessaging>
Handle class Handle : SingleMessageRecipient
InMemoryMessaging inner class InMemoryMessaging : SingletonSerializeAsToken, MessagingService

An InMemoryMessaging provides a MessagingService that isnt backed by any kind of network or disk storage system, but just uses regular queues on the heap instead. It is intended for unit testing and developer convenience when all entities on the network are being simulated in-process.

LatencyCalculator interface LatencyCalculator
MessageTransfer data class MessageTransfer

Constructors

<init> InMemoryMessagingNetwork()

An in-memory network allows you to manufacture InMemoryMessagings for a set of participants. Each InMemoryMessaging 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).

Properties

allMessages val allMessages: <ERROR CLASS><MessageTransfer>

A stream of (sender, message, recipients) triples

endpoints val endpoints: List<InMemoryMessaging>
everyoneOnline val everyoneOnline: AllPossibleRecipients
latencyCalculator var latencyCalculator: LatencyCalculator?

This can be set to an object which can inject artificial latency between sender/recipient pairs.

Functions

createNode fun createNode(manuallyPumped: Boolean): <ERROR CLASS><Handle, MessagingServiceBuilder<InMemoryMessaging>>

Creates a node and returns the new object that identifies its location on the network to senders, and the InMemoryMessaging that the recipient/in-memory node uses to receive messages and send messages itself.

createNodeWithID fun createNodeWithID(manuallyPumped: Boolean, id: Int, description: String? = null): MessagingServiceBuilder<InMemoryMessaging>

Creates a node at the given address: useful if you want to recreate a node to simulate a restart.

stop fun stop(): Unit

Inherited Functions

toToken open fun toToken(context: SerializeAsTokenContext): SerializationToken

Companion Object Properties

MESSAGES_LOG_NAME val MESSAGES_LOG_NAME: String