Package com.tnsai.coordination.messaging
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 ClassesModifier and TypeInterfaceDescriptionstatic classException for message broker operations.Nested classes/interfaces inherited from interface com.tnsai.spi.MessageBroker
com.tnsai.spi.MessageBroker.Message -
Method Summary
Modifier and TypeMethodDescriptionvoidConnects to the distributed backend.voidDisconnects from the distributed backend.getType()Returns the broker type identifier (e.g., "redis", "kafka", "nats").booleanReturns whether the broker is currently connected.ping()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
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
CompletableFuture<Long> ping()Pings the backend to check connectivity.- Returns:
- future completing with round-trip latency in milliseconds
-