Interface DistributedMessageBroker

All Superinterfaces:
com.tnsai.spi.MessageBroker

public interface DistributedMessageBroker extends com.tnsai.spi.MessageBroker
Extended MessageBroker interface for distributed messaging backends.

Adds capabilities beyond the core MessageBroker that are needed for distributed deployments: cluster awareness, partitioning, and delivery guarantees.

Implementations should be discovered via SPI using META-INF/services/com.tnsai.coordination.messaging.DistributedMessageBroker.

Usage


 DistributedMessageBroker broker = DistributedMessageBrokerFactory.create("redis");
 broker.connect(Map.of("host", "localhost", "port", "6379"));

 broker.publish("tasks", Message.of("Process data"));
 
Since:
0.2.3
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Exception for message broker operations.

    Nested classes/interfaces inherited from interface com.tnsai.spi.MessageBroker

    com.tnsai.spi.MessageBroker.Message
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Connects to the distributed backend.
    void
    Disconnects from the distributed backend.
    Returns the broker type identifier (e.g., "redis", "kafka", "nats").
    boolean
    Returns whether the broker is currently connected.
    Pings the backend to check connectivity.

    Methods inherited from interface com.tnsai.spi.MessageBroker

    broadcast, close, publish, request, send, subscribe, subscribeTopic, unsubscribe
  • Method Details

    • getType

      String getType()
      Returns the broker type identifier (e.g., "redis", "kafka", "nats").
      Returns:
      broker type name in lowercase
    • connect

      void connect(Map<String,String> config)
      Connects to the distributed backend.
      Parameters:
      config - connection configuration (host, port, credentials, etc.)
      Throws:
      DistributedMessageBroker.MessageBrokerException - if connection fails
    • disconnect

      void disconnect()
      Disconnects from the distributed backend.
    • isConnected

      boolean isConnected()
      Returns whether the broker is currently connected.
      Returns:
      true if connected
    • ping

      Pings the backend to check connectivity.
      Returns:
      future completing with round-trip latency in milliseconds