Interface MessageTransport

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
InMemoryTransport

public interface MessageTransport extends AutoCloseable
Byte-oriented publish/subscribe transport used by Relay's typed messaging layer.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Stops publication and reception and releases transport resources.
    boolean
    Reports current transport connectivity.
    publish(String channel, byte[] payload)
    Publishes bytes to one transport channel.
    default boolean
    Reports publication-side connectivity.
    long
    Returns the number of successful subscriber reconnections.
    void
    start(Collection<String> channels, BiConsumer<String,byte[]> receiver)
    Starts receiving messages from a fixed set of channels.
    default boolean
    Reports subscription-side connectivity.
  • Method Details

    • publish

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

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

      boolean connected()
      Reports current transport connectivity.
      Returns:
      true when connected
    • publisherConnected

      default boolean publisherConnected()
      Reports publication-side connectivity.
      Returns:
      true when the transport can currently publish
    • subscriberConnected

      default boolean subscriberConnected()
      Reports subscription-side connectivity.
      Returns:
      true when the transport is currently subscribed
    • reconnects

      long reconnects()
      Returns the number of successful subscriber reconnections.
      Returns:
      reconnect count
    • close

      void close()
      Stops publication and reception and releases transport resources.
      Specified by:
      close in interface AutoCloseable