Interface GenericGateway

All Superinterfaces:
HasLocalHandlers
All Known Implementing Classes:
DefaultGenericGateway

public interface GenericGateway extends HasLocalHandlers
A generic message gateway for publication of messages in Flux Capacitor.

The GenericGateway provides a uniform interface to send and receive messages over any standard or user-defined topic, enabling extensibility beyond the default types such as commands, queries, events, and errors.

This interface supports asynchronous and synchronous message dispatching, both with and without awaiting a result. It also includes support for delivery guarantees and local handler registration.

Typical usage includes:

  • Custom message flows that don’t fit standard message types
  • Internal APIs that benefit from topic-based routing
  • Feature-specific messaging with isolated topics

Obtaining a Gateway

Use FluxCapacitor.customGateway(String) to create or retrieve a GenericGateway for a given topic:

 GenericGateway myGateway = FluxCapacitor.customGateway("myTopic");
 
See Also:
  • Method Details

    • sendAndForget

      default void sendAndForget(Object message)
      Sends a message asynchronously without waiting for a result or acknowledgement.
    • sendAndForget

      default void sendAndForget(Object payload, Metadata metadata)
      Sends a message with custom payload and metadata asynchronously.
    • sendAndForget

      default void sendAndForget(Object payload, Metadata metadata, Guarantee guarantee)
      Sends a message with payload, metadata, and delivery guarantee asynchronously.
    • sendAndForget

      default CompletableFuture<Void> sendAndForget(Message message, Guarantee guarantee)
      Sends a Message asynchronously with a given guarantee.
    • sendAndForget

      default void sendAndForget(Object... messages)
      Sends multiple messages asynchronously with Guarantee.NONE.
    • sendAndForget

      default CompletableFuture<Void> sendAndForget(Guarantee guarantee, Object... messages)
      Sends multiple messages asynchronously with a specified delivery guarantee.
    • sendAndForget

      CompletableFuture<Void> sendAndForget(Guarantee guarantee, Message... messages)
      Sends multiple Message objects with a guarantee.
    • send

      default <R> CompletableFuture<R> send(Message message)
      Sends a Message and returns a future that completes with its response payload.
    • send

      default <R> CompletableFuture<R> send(Object message)
      Sends a message (raw object or Request) and returns a future with its response.
    • send

      default <R> CompletableFuture<R> send(Request<R> message)
      Sends a Request message and returns a future with its typed response.
    • send

      default <R> CompletableFuture<R> send(Object payload, Metadata metadata)
      Sends a message with custom metadata and returns a future with its response.
    • send

      default <R> CompletableFuture<R> send(Request<R> payload, Metadata metadata)
      Sends a Request with metadata and returns a future with its response.
    • sendForMessage

      default CompletableFuture<Message> sendForMessage(Message message)
      Sends a single Message and returns a future that resolves to the complete Message response.
    • send

      default <R> List<CompletableFuture<R>> send(Object... messages)
      Sends multiple messages and returns a list of futures with their payload responses.
    • sendForMessages

      List<CompletableFuture<Message>> sendForMessages(Message... messages)
      Sends multiple messages and returns futures for their full Message responses.
    • sendAndWait

      default <R> R sendAndWait(Object message)
      Sends a message and blocks until a response is received.
    • sendAndWait

      default <R> R sendAndWait(Request<R> message)
      Sends a Request and blocks until a response is received.
    • sendAndWait

      default <R> R sendAndWait(Object payload, Metadata metadata)
      Sends a message with metadata and blocks for a response.
    • sendAndWait

      default <R> R sendAndWait(Request<R> payload, Metadata metadata)
      Sends a Request with metadata and blocks for a response.
    • sendAndWait

      default <R> R sendAndWait(Message message)
      Sends a message and blocks for a result with a configurable timeout.

      Timeout can be customized using @Timeout on the payload class.

    • setRetentionTime

      default void setRetentionTime(Duration duration)
      Set a new retention duration for the underlying gateway's message log.

      The retention setting determines how long messages in this log are retained by the system, after which they may be evicted or deleted depending on the platform policy.

      Parameters:
      duration - the new retention duration
    • setRetentionTime

      CompletableFuture<Void> setRetentionTime(Duration duration, Guarantee guarantee)
      Set a new retention duration for the underlying gateway's message log.

      The retention setting determines how long messages in this log are retained by the system, after which they may be evicted or deleted depending on the platform policy.

      Parameters:
      duration - the new retention duration
      guarantee - the delivery guarantee to apply to the update operation
      Returns:
      a CompletableFuture that completes once the retention setting is updated
    • close

      void close()
      Closes this gateway and releases any underlying resources.