Interface ExternalCommunicationDecorator

All Superinterfaces:
CommonDecorator
All Known Subinterfaces:
Communication, FlowAttachmentCommunication, FlowBindingLogicServerCommunication, FlowContext, FlowExternalCommunication, FlowExternalWriteCommunication, FLowUserIdSettingCommunication
All Known Implementing Classes:
DefaultCommunication, DefaultFlowContext

public interface ExternalCommunicationDecorator extends CommonDecorator
Decorator interface providing convenience methods for communicating with external (client-facing) servers.

Offers three invocation styles for each operation:

  • Synchronous -- blocking call returning the response directly
  • Future -- returning a CompletableFuture for non-blocking composition
  • Async callback -- accepting a Consumer executed on the current or a supplied Executor
Also supports collect-style calls that aggregate responses from multiple external servers, and logic-server binding.
Since:
25.1
Author:
渔民小镇
date:
2025-09-28
  • Method Details

    • ofExternalRequestMessage

      ExternalRequestMessage ofExternalRequestMessage(int templateId, byte[] payload)
      Create an ExternalRequestMessage with the given template ID and payload.
      Parameters:
      templateId - the external request template identifier
      payload - the serialized request payload (may be null)
      Returns:
      a new external request message
    • ofExternalRequestMessage

      default ExternalRequestMessage ofExternalRequestMessage(int templateId)
      Create an ExternalRequestMessage with the given template ID and no payload.
      Parameters:
      templateId - the external request template identifier
      Returns:
      a new external request message with null payload
    • callExternal

      default ExternalResponse callExternal(ExternalRequestMessage message)
      Synchronously call a single external server.
      Parameters:
      message - the external request message
      Returns:
      the external server response
    • callExternal

      default ExternalResponse callExternal(int templateId, byte[] payload)
      Synchronously call a single external server with the given template ID and payload.
      Parameters:
      templateId - the external request template identifier
      payload - the serialized request payload
      Returns:
      the external server response
    • callExternal

      default ExternalResponse callExternal(int templateId)
      Synchronously call a single external server with the given template ID and no payload.
      Parameters:
      templateId - the external request template identifier
      Returns:
      the external server response
    • callExternalFuture

      default CompletableFuture<ExternalResponse> callExternalFuture(ExternalRequestMessage message)
      Asynchronously call a single external server, returning a future.
      Parameters:
      message - the external request message
      Returns:
      a future that completes with the external server response
    • callExternalFuture

      default CompletableFuture<ExternalResponse> callExternalFuture(int templateId, byte[] payload)
      Asynchronously call a single external server with the given template ID and payload.
      Parameters:
      templateId - the external request template identifier
      payload - the serialized request payload
      Returns:
      a future that completes with the external server response
    • callExternalFuture

      default CompletableFuture<ExternalResponse> callExternalFuture(int templateId)
      Asynchronously call a single external server with the given template ID and no payload.
      Parameters:
      templateId - the external request template identifier
      Returns:
      a future that completes with the external server response
    • callExternalAsync

      default void callExternalAsync(ExternalRequestMessage message, Consumer<ExternalResponse> action)
      Call a single external server asynchronously and invoke the callback on the current executor.
      Parameters:
      message - the external request message
      action - the callback to invoke with the response
    • callExternalAsync

      default void callExternalAsync(ExternalRequestMessage message, Consumer<ExternalResponse> action, Executor executor)
      Call a single external server asynchronously and invoke the callback on the supplied executor.
      Parameters:
      message - the external request message
      action - the callback to invoke with the response
      executor - the executor on which to run the callback
    • callExternalAsync

      default void callExternalAsync(int templateId, byte[] payload, Consumer<ExternalResponse> action)
      Call a single external server asynchronously with the given template ID and payload.
      Parameters:
      templateId - the external request template identifier
      payload - the serialized request payload
      action - the callback to invoke with the response
    • callExternalAsync

      default void callExternalAsync(int templateId, Consumer<ExternalResponse> action)
      Call a single external server asynchronously with the given template ID and no payload.
      Parameters:
      templateId - the external request template identifier
      action - the callback to invoke with the response
    • callExternalCollect

      default ResponseCollectExternal callExternalCollect(ExternalRequestMessage message)
      Synchronously call all external servers and collect their aggregated responses.
      Parameters:
      message - the external request message
      Returns:
      the aggregated response from all external servers
    • callExternalCollect

      default ResponseCollectExternal callExternalCollect(int templateId, byte[] payload)
      Synchronously call all external servers with the given template ID and payload.
      Parameters:
      templateId - the external request template identifier
      payload - the serialized request payload
      Returns:
      the aggregated response from all external servers
    • callExternalCollect

      default ResponseCollectExternal callExternalCollect(int templateId)
      Synchronously call all external servers with the given template ID and no payload.
      Parameters:
      templateId - the external request template identifier
      Returns:
      the aggregated response from all external servers
    • callExternalCollectFuture

      default CompletableFuture<ResponseCollectExternal> callExternalCollectFuture(ExternalRequestMessage message)
      Asynchronously call all external servers and collect their aggregated responses.
      Parameters:
      message - the external request message
      Returns:
      a future that completes with the aggregated response
    • callExternalCollectFuture

      default CompletableFuture<ResponseCollectExternal> callExternalCollectFuture(int templateId, byte[] payload)
      Asynchronously call all external servers with the given template ID and payload.
      Parameters:
      templateId - the external request template identifier
      payload - the serialized request payload
      Returns:
      a future that completes with the aggregated response
    • callExternalCollectFuture

      default CompletableFuture<ResponseCollectExternal> callExternalCollectFuture(int templateId)
      Asynchronously call all external servers with the given template ID and no payload.
      Parameters:
      templateId - the external request template identifier
      Returns:
      a future that completes with the aggregated response
    • callExternalCollectAsync

      default void callExternalCollectAsync(ExternalRequestMessage message, Consumer<ResponseCollectExternal> action)
      Call all external servers asynchronously and invoke the callback on the current executor.
      Parameters:
      message - the external request message
      action - the callback to invoke with the aggregated response
    • callExternalCollectAsync

      default void callExternalCollectAsync(ExternalRequestMessage message, Consumer<ResponseCollectExternal> action, Executor executor)
      Call all external servers asynchronously and invoke the callback on the supplied executor.
      Parameters:
      message - the external request message
      action - the callback to invoke with the aggregated response
      executor - the executor on which to run the callback
    • callExternalCollectAsync

      default void callExternalCollectAsync(int templateId, byte[] payload, Consumer<ResponseCollectExternal> action)
      Call all external servers asynchronously with the given template ID and payload.
      Parameters:
      templateId - the external request template identifier
      payload - the serialized request payload
      action - the callback to invoke with the aggregated response
    • callExternalCollectAsync

      default void callExternalCollectAsync(int templateId, Consumer<ResponseCollectExternal> action)
      Call all external servers asynchronously with the given template ID and no payload.
      Parameters:
      templateId - the external request template identifier
      action - the callback to invoke with the aggregated response
    • bindingLogicServer

      default CommonResponse bindingLogicServer(BindingLogicServerMessage message)
      Bind a user session to a specific logic server.
      Parameters:
      message - the binding request message
      Returns:
      the common response indicating success or failure