Class InMemoryTransport

java.lang.Object
com.iantapply.relay.core.InMemoryTransport
All Implemented Interfaces:
MessageTransport, AutoCloseable

public final class InMemoryTransport extends Object implements MessageTransport
Deterministic transport for contract tests and local embedding.
  • Constructor Details

    • InMemoryTransport

      public InMemoryTransport()
      Creates a disconnected in-memory transport.
  • Method Details

    • publish

      public CompletionStage<Void> publish(String channel, byte[] payload)
      Description copied from interface: MessageTransport
      Publishes bytes to one transport channel.
      Specified by:
      publish in interface MessageTransport
      Parameters:
      channel - destination channel
      payload - encoded Relay envelope
      Returns:
      stage completed when the transport accepts the publication
    • start

      public void start(Collection<String> channels, BiConsumer<String,byte[]> receiver)
      Description copied from interface: MessageTransport
      Starts receiving messages from a fixed set of channels.
      Specified by:
      start in interface MessageTransport
      Parameters:
      channels - channels to consume
      receiver - callback receiving a channel and encoded envelope
    • connected

      public boolean connected()
      Description copied from interface: MessageTransport
      Reports current transport connectivity.
      Specified by:
      connected in interface MessageTransport
      Returns:
      true when connected
    • reconnects

      public long reconnects()
      Description copied from interface: MessageTransport
      Returns the number of successful subscriber reconnections.
      Specified by:
      reconnects in interface MessageTransport
      Returns:
      reconnect count
    • close

      public void close()
      Description copied from interface: MessageTransport
      Stops publication and reception and releases transport resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface MessageTransport