Class DistributedMessageBrokerFactory

java.lang.Object
com.tnsai.coordination.messaging.DistributedMessageBrokerFactory

public final class DistributedMessageBrokerFactory extends Object
SPI-based factory for discovering and creating DistributedMessageBroker instances.

Implementations are discovered via META-INF/services/com.tnsai.coordination.messaging.DistributedMessageBroker. Each implementation is identified by its DistributedMessageBroker.getType() value.

Usage


 // Discover all available broker types
 List<String> types = DistributedMessageBrokerFactory.availableTypes();
 // -> ["redis", "nats"]

 // Create a specific broker
 DistributedMessageBroker broker = DistributedMessageBrokerFactory.create("redis");
 broker.connect(Map.of("host", "localhost"));
 
Since:
0.2.3
See Also:
  • Method Details

    • create

      public static DistributedMessageBroker create(String type)
      Creates a distributed message broker by type.
      Parameters:
      type - the broker type (e.g., "redis", "kafka")
      Returns:
      the broker instance
      Throws:
      NoSuchElementException - if no broker of the given type is registered
    • availableTypes

      public static List<String> availableTypes()
      Returns the types of all available brokers discovered via SPI.
      Returns:
      list of broker type names
    • isAvailable

      public static boolean isAvailable(String type)
      Checks whether a broker type is available.
      Parameters:
      type - the broker type to check
      Returns:
      true if a broker of this type is registered