Interface Transport

All Known Implementing Classes:
MockTransport, NioTcpTransport, NioUdpTransport, TCPTransport, UDPTransport

public interface Transport
Defines a transport mechanism for communication between services, JVMs, or devices. Implementations of this interface may use various protocols such as TCP, UDP, or other interoperable messaging systems to deliver messages across network boundaries.

The transport supports two messaging patterns:

  • Send: Point-to-point delivery to a single recipient.
  • Publish: Broadcast delivery to multiple recipients subscribed to an address.

Implementations must also provide lifecycle management through start() and shutdown() methods.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    publish(String host, int port, String address, Object message)
    Publishes a message to all subscribers of the specified address.
    void
    register(String address, Consumer<Object> handler)
    Registers a handler for messages received on the specified address.
    void
    send(String host, int port, String address, Object message)
    Sends a message to a specific host and port using point-to-point delivery.
    void
    Shuts down the transport mechanism and releases any allocated resources.
    void
    Starts the transport mechanism, initializing resources such as sockets or threads.
  • Method Details

    • send

      void send(String host, int port, String address, Object message)
      Sends a message to a specific host and port using point-to-point delivery.
      Parameters:
      host - the target host
      port - the target port
      address - the logical address or topic for the message
      message - the message to send
    • publish

      void publish(String host, int port, String address, Object message)
      Publishes a message to all subscribers of the specified address.
      Parameters:
      host - the target host
      port - the target port
      address - the logical address or topic for the message
      message - the message to broadcast
    • register

      void register(String address, Consumer<Object> handler)
      Registers a handler for messages received on the specified address.
      Parameters:
      address - the address or topic to listen on
      handler - a Consumer that processes incoming messages
    • start

      void start()
      Starts the transport mechanism, initializing resources such as sockets or threads.
    • shutdown

      void shutdown()
      Shuts down the transport mechanism and releases any allocated resources.