Interface MessageSizeStrategy

All Superinterfaces:
AutoCloseable, Service, StaticService

public interface MessageSizeStrategy extends 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 Type
    Method
    Description
    long
    Computes the size of the message body in bytes.
    long
    Computes the total size of all message headers in bytes (keys and values).
    boolean
    Whether message size computation is enabled.
    void
    setEnabled(boolean enabled)
    Whether message size computation is enabled.

    Methods inherited from interface Service

    build, close, init, start, stop
  • Method Details

    • setEnabled

      void setEnabled(boolean enabled)
      Whether message size computation is enabled.
    • isEnabled

      boolean isEnabled()
      Whether message size computation is enabled.
    • computeBodySize

      long computeBodySize(Message message)
      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

      long computeHeadersSize(Message message)
      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