Interface ExternalCommunicationDecorator
- All Superinterfaces:
CommonDecorator
- All Known Subinterfaces:
Communication, FlowAttachmentCommunication, FlowBindingLogicServerCommunication, FlowContext, FlowExternalCommunication, FlowExternalWriteCommunication, FLowUserIdSettingCommunication
- All Known Implementing Classes:
DefaultCommunication, DefaultFlowContext
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
CompletableFuturefor non-blocking composition - Async callback -- accepting a
Consumerexecuted on the current or a suppliedExecutor
- Since:
- 25.1
- Author:
- 渔民小镇
- date:
- 2025-09-28
-
Method Summary
Modifier and TypeMethodDescriptiondefault CommonResponseBind a user session to a specific logic server.default ExternalResponsecallExternal(int templateId) Synchronously call a single external server with the given template ID and no payload.default ExternalResponsecallExternal(int templateId, byte[] payload) Synchronously call a single external server with the given template ID and payload.default ExternalResponsecallExternal(ExternalRequestMessage message) Synchronously call a single external server.default voidcallExternalAsync(int templateId, byte[] payload, Consumer<ExternalResponse> action) Call a single external server asynchronously with the given template ID and payload.default voidcallExternalAsync(int templateId, Consumer<ExternalResponse> action) Call a single external server asynchronously with the given template ID and no payload.default voidcallExternalAsync(ExternalRequestMessage message, Consumer<ExternalResponse> action) Call a single external server asynchronously and invoke the callback on the current executor.default voidcallExternalAsync(ExternalRequestMessage message, Consumer<ExternalResponse> action, Executor executor) Call a single external server asynchronously and invoke the callback on the supplied executor.default ResponseCollectExternalcallExternalCollect(int templateId) Synchronously call all external servers with the given template ID and no payload.default ResponseCollectExternalcallExternalCollect(int templateId, byte[] payload) Synchronously call all external servers with the given template ID and payload.default ResponseCollectExternalSynchronously call all external servers and collect their aggregated responses.default voidcallExternalCollectAsync(int templateId, byte[] payload, Consumer<ResponseCollectExternal> action) Call all external servers asynchronously with the given template ID and payload.default voidcallExternalCollectAsync(int templateId, Consumer<ResponseCollectExternal> action) Call all external servers asynchronously with the given template ID and no payload.default voidcallExternalCollectAsync(ExternalRequestMessage message, Consumer<ResponseCollectExternal> action) Call all external servers asynchronously and invoke the callback on the current executor.default voidcallExternalCollectAsync(ExternalRequestMessage message, Consumer<ResponseCollectExternal> action, Executor executor) Call all external servers asynchronously and invoke the callback on the supplied executor.default CompletableFuture<ResponseCollectExternal> callExternalCollectFuture(int templateId) Asynchronously call all external servers with the given template ID and no payload.default CompletableFuture<ResponseCollectExternal> callExternalCollectFuture(int templateId, byte[] payload) Asynchronously call all external servers with the given template ID and payload.default CompletableFuture<ResponseCollectExternal> Asynchronously call all external servers and collect their aggregated responses.default CompletableFuture<ExternalResponse> callExternalFuture(int templateId) Asynchronously call a single external server with the given template ID and no payload.default CompletableFuture<ExternalResponse> callExternalFuture(int templateId, byte[] payload) Asynchronously call a single external server with the given template ID and payload.default CompletableFuture<ExternalResponse> callExternalFuture(ExternalRequestMessage message) Asynchronously call a single external server, returning a future.default ExternalRequestMessageofExternalRequestMessage(int templateId) Create anExternalRequestMessagewith the given template ID and no payload.ofExternalRequestMessage(int templateId, byte[] payload) Create anExternalRequestMessagewith the given template ID and payload.Methods inherited from interface CommonDecorator
getCommunicationAggregation, getCurrentExecutor, getTraceId
-
Method Details
-
ofExternalRequestMessage
Create anExternalRequestMessagewith the given template ID and payload.- Parameters:
templateId- the external request template identifierpayload- the serialized request payload (may benull)- Returns:
- a new external request message
-
ofExternalRequestMessage
Create anExternalRequestMessagewith the given template ID and no payload.- Parameters:
templateId- the external request template identifier- Returns:
- a new external request message with
nullpayload
-
callExternal
Synchronously call a single external server.- Parameters:
message- the external request message- Returns:
- the external server response
-
callExternal
Synchronously call a single external server with the given template ID and payload.- Parameters:
templateId- the external request template identifierpayload- the serialized request payload- Returns:
- the external server response
-
callExternal
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
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
Asynchronously call a single external server with the given template ID and payload.- Parameters:
templateId- the external request template identifierpayload- the serialized request payload- Returns:
- a future that completes with the external server response
-
callExternalFuture
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
Call a single external server asynchronously and invoke the callback on the current executor.- Parameters:
message- the external request messageaction- 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 messageaction- the callback to invoke with the responseexecutor- the executor on which to run the callback
-
callExternalAsync
Call a single external server asynchronously with the given template ID and payload.- Parameters:
templateId- the external request template identifierpayload- the serialized request payloadaction- the callback to invoke with the response
-
callExternalAsync
Call a single external server asynchronously with the given template ID and no payload.- Parameters:
templateId- the external request template identifieraction- the callback to invoke with the response
-
callExternalCollect
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
Synchronously call all external servers with the given template ID and payload.- Parameters:
templateId- the external request template identifierpayload- the serialized request payload- Returns:
- the aggregated response from all external servers
-
callExternalCollect
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 identifierpayload- the serialized request payload- Returns:
- a future that completes with the aggregated response
-
callExternalCollectFuture
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 messageaction- 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 messageaction- the callback to invoke with the aggregated responseexecutor- 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 identifierpayload- the serialized request payloadaction- the callback to invoke with the aggregated response
-
callExternalCollectAsync
Call all external servers asynchronously with the given template ID and no payload.- Parameters:
templateId- the external request template identifieraction- the callback to invoke with the aggregated response
-
bindingLogicServer
Bind a user session to a specific logic server.- Parameters:
message- the binding request message- Returns:
- the common response indicating success or failure
-