Class WebsocketGatewayClient

java.lang.Object
io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
io.fluxcapacitor.javaclient.publishing.client.WebsocketGatewayClient
All Implemented Interfaces:
Monitored<List<SerializedMessage>>, GatewayClient, AutoCloseable

public class WebsocketGatewayClient extends AbstractWebsocketClient implements GatewayClient
A GatewayClient implementation that sends serialized messages to the Flux Platform over a WebSocket connection.

This client is used internally by the Flux Capacitor framework to publish messages (commands, events, queries, etc.) to the platform backend in a reliable, asynchronous manner. It wraps around a WebSocket transport managed by AbstractWebsocketClient and uses a low-level protocol to dispatch messages as SerializedMessage objects.

Usage: Users typically do not use this class directly. Instead, messages are dispatched using higher-level APIs like CommandGateway or static functions in FluxCapacitor.

Each WebsocketGatewayClient instance is bound to a specific MessageType and topic. Metrics are optionally sent with each dispatch (enabled by default except for METRICS message gateway clients to prevent infinite recursion).

Features:

  • Supports append operations with configurable delivery Guarantee.
  • Tracks sent messages via registered monitors for observability or auditing purposes.
  • Allows retention time settings to be adjusted on the gateway (if supported).
See Also:
  • Constructor Details

    • WebsocketGatewayClient

      public WebsocketGatewayClient(String endPointUrl, WebSocketClient client, MessageType type, String topic)
      Constructs a new WebsocketGatewayClient instance using the specified parameters. This constructor initializes the client to connect to a specific WebSocket endpoint for a given message type and topic.

      Metrics messages are enabled unless messageType is MessageType.METRICS.

      Parameters:
      endPointUrl - the WebSocket base endpoint URI to connect to
      client - the WebSocketClient instance used for configuration
      type - the MessageType defining the category of messages this client handles
      topic - the topic associated with the messages handled by this client if MessageType is MessageType.CUSTOM or MessageType.DOCUMENT or null otherwise
    • WebsocketGatewayClient

      public WebsocketGatewayClient(URI endPointUri, WebSocketClient client, MessageType type, String topic, boolean sendMetrics)
      Constructs a new WebsocketGatewayClient instance using the specified parameters. This constructor initializes the client to connect to a specific WebSocket endpoint for a given message type and topic.
      Parameters:
      endPointUri - the WebSocket base endpoint URI to connect to
      client - the WebSocketClient instance used for configuration
      type - the MessageType defining the category of messages this client handles
      topic - the topic associated with the messages handled by this client if MessageType is MessageType.CUSTOM or MessageType.DOCUMENT or null otherwise
      sendMetrics - a flag indicating whether metrics should be enabled for this client
  • Method Details