Package io.bytestreams.exchange.core
Class SymmetricChannel<T>
java.lang.Object
io.bytestreams.exchange.core.AbstractChannel<T,T>
io.bytestreams.exchange.core.MultiplexedChannel<T,T>
io.bytestreams.exchange.core.SymmetricChannel<T>
- Type Parameters:
T- the message type (used for both requests and responses)
- All Implemented Interfaces:
Channel,ClientChannel<T,T>
A
MultiplexedChannel where request and response types are the same (T=T),
enabling bidirectional symmetric messaging on a single connection.
Outbound requests are multiplexed by message ID (via ClientChannel.request(REQ)). Inbound messages that
cannot be correlated to a pending outbound request are treated as new inbound requests and
dispatched to the registered RequestHandler, which completes a future whose result is
enqueued for writing back to the remote peer.
The channel uses SpanKind.INTERNAL and reports channel_type=symmetric in OTel
metrics. Outbound requests carry direction=outbound; inbound requests carry
direction=inbound.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ErrorHandler<T, T> protected final io.opentelemetry.api.trace.Tracerprotected final ObjectFields inherited from class io.bytestreams.exchange.core.AbstractChannel
channelSpan, closeFuture, DEFAULT_ERROR_BACKOFF_NANOS, defaultTimeout, meterAttributes, readFuture, requestActive, requestDuration, requestErrors, requestTotal, SHUTTING_DOWN, status, transport, writeQueue, writeQueueSize -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected voidonUncorrelatedMessage(T message) Called by the read loop for inbound messages that cannot be correlated to a pending outbound request.Sends a message using the channel's configured default timeout and returns a future that completes when a correlated response arrives.Sends a message with a per-request timeout override.static <T> SymmetricChannel.Builder<T> Methods inherited from class io.bytestreams.exchange.core.MultiplexedChannel
builder, onInboundMethods inherited from class io.bytestreams.exchange.core.AbstractChannel
buildMessageAttributes, close, closeFuture, id, interruptIfDrained, start, status
-
Field Details
-
tracer
protected final io.opentelemetry.api.trace.Tracer tracer -
writeLock
-
errorHandler
-
-
Method Details
-
symmetricBuilder
-
hasPending
protected boolean hasPending()- Overrides:
hasPendingin classMultiplexedChannel<T,T>
-
request
Description copied from interface:ClientChannelSends a message using the channel's configured default timeout and returns a future that completes when a correlated response arrives.- Specified by:
requestin interfaceClientChannel<REQ,RESP> - Parameters:
request- the message to send- Returns:
- a future that completes with the correlated response
-
request
Description copied from interface:ClientChannelSends a message with a per-request timeout override.- Specified by:
requestin interfaceClientChannel<REQ,RESP> - Parameters:
request- the message to sendtimeout- the timeout for this request; must be positive- Returns:
- a future that completes with the correlated response
-