Interface MessageSizeStrategy
- All Superinterfaces:
AutoCloseable, Service, StaticService
Strategy for computing the size of message payloads (body and headers) for observation purposes.
Not all message body types can be sized efficiently. For example, Java objects have no inherent "size", and streaming
payloads would be destructive to read unless stream caching is enabled. Implementations should return -1 when the
size cannot be determined without side effects.
- Since:
- 4.21
-
Method Summary
Modifier and TypeMethodDescriptionlongcomputeBodySize(Message message) Computes the size of the message body in bytes.longcomputeHeadersSize(Message message) Computes the total size of all message headers in bytes (keys and values).booleanWhether message size computation is enabled.voidsetEnabled(boolean enabled) Whether message size computation is enabled.
-
Method Details
-
setEnabled
void setEnabled(boolean enabled) Whether message size computation is enabled. -
isEnabled
boolean isEnabled()Whether message size computation is enabled. -
computeBodySize
Computes the size of the message body in bytes.- Parameters:
message- the message- Returns:
- the body size in bytes, 0 if the body is null, or -1 if the size cannot be determined
-
computeHeadersSize
Computes the total size of all message headers in bytes (keys and values).- Parameters:
message- the message- Returns:
- the total headers size in bytes, or -1 if the size cannot be determined
-