Package net.bitbylogic.rps.client
Class RedisClient
java.lang.Object
net.bitbylogic.rps.client.RedisClient
-
Constructor Summary
ConstructorsConstructorDescriptionRedisClient(@NotNull RedisManager redisManager, @NotNull String clientId) Constructs a new RedisClient instance with the specified RedisManager and client ID. -
Method Summary
Modifier and TypeMethodDescriptionorg.redisson.api.RedissonClientRetrieves the Redisson client instance used to interact with Redis.voidregisterListener(@NotNull RedisMessageListener listener) Registers a Redis message listener with the client.voidsendListenerMessage(@NotNull ListenerComponent component) Sends a listener message to a Redis topic and handles timed requests associated with the message.voidsendTimedResponse(@NotNull ListenerComponent component) Sends a timed response message using the specifiedListenerComponent.
-
Constructor Details
-
RedisClient
Constructs a new RedisClient instance with the specified RedisManager and client ID. Initializes the client with the server ID retrieved from the RedisManager and registers the request topic for message handling.- Parameters:
redisManager- The RedisManager instance responsible for managing Redis operations. Must not be null.clientId- The unique identifier for this RedisClient instance. Must not be null.
-
-
Method Details
-
registerListener
Registers a Redis message listener with the client. This method ensures that the provided listener is not already registered. If the listener is being registered for the first time, it is added to the internal list of listeners, associated with the current client instance, and the listener's subscription channel is registered for incoming messages.- Parameters:
listener- The Redis message listener to register. Must not be null.
-
sendListenerMessage
Sends a listener message to a Redis topic and handles timed requests associated with the message. This method binds the providedListenerComponentto the currentRedisClientinstance as its source, processes any timed requests defined in the component, and publishes the message to a Redis topic. Debug information can also be logged if enabled in the RedisManager.- Parameters:
component- TheListenerComponentto be sent. Must not be null. The component encapsulates channel, target server, data, and potentially timed requests.
-
sendTimedResponse
Sends a timed response message using the specifiedListenerComponent. This method binds the providedListenerComponentto the currentRedisClientinstance as its source, verifies that at least one timed response is defined in the component, and then publishes the component as a message to a Redis topic. If debug mode is enabled in theRedisManager, debug information about the operation is logged.- Parameters:
component- TheListenerComponentcontaining the timed responses to be sent. Must not be null
-
getRedisClient
public org.redisson.api.RedissonClient getRedisClient()Retrieves the Redisson client instance used to interact with Redis.This method provides access to the underlying
RedissonClientwhich enables operations such as data storage, messaging, and synchronization across Redis.- Returns:
- the
RedissonClientinstance managed by theredisManager.
-