InMemoryMessagingNetwork
Keywords: net.corda.testing.node.InMemoryMessagingNetwork class
Date: 2023-09-18

net.corda.testing.node

## Class InMemoryMessagingNetwork

- net.corda.core.serialization.SingletonSerializeAsToken
- - net.corda.testing.node.InMemoryMessagingNetwork

- All Implemented Interfaces:
    SerializeAsToken

      @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).

- - ### Field Detail

    - #### Companion

          public static net.corda.testing.node.InMemoryMessagingNetwork.Companion Companion

  - ### Method Detail

    - #### getSentMessages

          @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`.

      See Also:
        `pumpSend`

    - #### getReceivedMessages

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

    - #### getEndpointsExternal

          @Synchronized
           @NotNull
          public java.util.List<net.corda.testing.node.InMemoryMessagingNetwork.MockMessagingService> getEndpointsExternal()

      Get a List of all the `class InMemoryMessagingNetwork.MockMessagingService` endpoints

      See Also:
        List, `class InMemoryMessagingNetwork.MockMessagingService`

    - #### stop

          public void stop()

      Stop all nodes within the network and clear any buffered messages

    - #### pumpSend

          @Nullable
          public net.corda.testing.node.InMemoryMessagingNetwork.MessageTransfer pumpSend(boolean block)

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

      Parameters:
        `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.