Class CommonMessage

java.lang.Object
com.iohao.net.framework.protocol.CommonMessage
All Implemented Interfaces:
FutureMessage, RemoteMessage
Direct Known Subclasses:
RequestMessage, ResponseMessage, UserRequestMessage, UserResponseMessage

public class CommonMessage extends Object implements RemoteMessage
Base class for internal messages exchanged between logic servers via Aeron.

Carries the common fields shared by all internal message types: the merged command route key (cmdMerge), trace identifier, server routing IDs (external, logic, source), network identifier, timing information, serialized payload data, and an optional error output. Subclasses extend this to add request- or response-specific fields.

Since:
25.1
Author:
渔民小镇
date:
2025-09-15
  • Field Details

    • futureId

      protected long futureId
    • cmdMerge

      protected int cmdMerge
    • traceId

      protected String traceId
    • externalServerId

      protected int externalServerId
    • logicServerId

      protected int logicServerId
    • sourceServerId

      protected int sourceServerId
    • nanoTime

      protected long nanoTime
    • netId

      protected int netId
    • data

      protected byte[] data
    • outputError

      protected ErrorInformation outputError
  • Constructor Details

    • CommonMessage

      public CommonMessage()
  • Method Details

    • setCmdInfo

      public void setCmdInfo(CmdInfo cmdInfo)
      Set the command route from a CmdInfo descriptor.
      Specified by:
      setCmdInfo in interface RemoteMessage
      Parameters:
      cmdInfo - the command info containing the merged route key
    • getCmdInfo

      public CmdInfo getCmdInfo()
      Derive the CmdInfo route descriptor from the merged command key.
      Specified by:
      getCmdInfo in interface RemoteMessage
      Returns:
      the command info
    • getFutureId

      public long getFutureId()
      Description copied from interface: FutureMessage
      Get the future correlation id.
      Specified by:
      getFutureId in interface FutureMessage
      Returns:
      the future id
    • getCmdMerge

      public int getCmdMerge()
      Description copied from interface: RemoteMessage
      Get the merged command route key (cmd + subCmd packed into a single int).
      Specified by:
      getCmdMerge in interface RemoteMessage
      Returns:
      the merged command key
    • getTraceId

      public String getTraceId()
      Description copied from interface: RemoteMessage
      Get the distributed trace ID for this message.
      Specified by:
      getTraceId in interface RemoteMessage
      Returns:
      the trace ID, or null if not set
    • getExternalServerId

      public int getExternalServerId()
      Description copied from interface: RemoteMessage
      Get the ID of the external server that originated or will receive this message.
      Specified by:
      getExternalServerId in interface RemoteMessage
      Returns:
      the external server ID
    • getLogicServerId

      public int getLogicServerId()
      Description copied from interface: RemoteMessage
      Get the ID of the logic server handling this message.
      Specified by:
      getLogicServerId in interface RemoteMessage
      Returns:
      the logic server ID
    • getSourceServerId

      public int getSourceServerId()
      Description copied from interface: RemoteMessage
      Get the ID of the server that originally created this message.
      Specified by:
      getSourceServerId in interface RemoteMessage
      Returns:
      the source server ID
    • getNanoTime

      public long getNanoTime()
      Description copied from interface: RemoteMessage
      Get the nanosecond timestamp recorded when this message was created or received.
      Specified by:
      getNanoTime in interface RemoteMessage
      Returns:
      the nano time
    • getNetId

      public int getNetId()
      Description copied from interface: RemoteMessage
      Get the network-level identifier.
      Specified by:
      getNetId in interface RemoteMessage
      Returns:
      the net ID
    • getData

      public byte[] getData()
      Description copied from interface: RemoteMessage
      Get the serialized payload data.
      Specified by:
      getData in interface RemoteMessage
      Returns:
      the payload byte array
    • getOutputError

      public ErrorInformation getOutputError()
    • setFutureId

      public void setFutureId(long futureId)
      Description copied from interface: FutureMessage
      Set the future correlation id.
      Specified by:
      setFutureId in interface FutureMessage
      Parameters:
      futureId - the future id
    • setCmdMerge

      public void setCmdMerge(int cmdMerge)
      Description copied from interface: RemoteMessage
      Set the merged command route key.
      Specified by:
      setCmdMerge in interface RemoteMessage
      Parameters:
      cmdMerge - the merged command key
    • setTraceId

      public void setTraceId(String traceId)
      Description copied from interface: RemoteMessage
      Set the distributed trace ID for this message.
      Specified by:
      setTraceId in interface RemoteMessage
      Parameters:
      traceId - the trace ID
    • setExternalServerId

      public void setExternalServerId(int externalServerId)
      Description copied from interface: RemoteMessage
      Set the ID of the external server.
      Specified by:
      setExternalServerId in interface RemoteMessage
      Parameters:
      externalServerId - the external server ID
    • setLogicServerId

      public void setLogicServerId(int logicServerId)
      Description copied from interface: RemoteMessage
      Set the ID of the logic server handling this message.
      Specified by:
      setLogicServerId in interface RemoteMessage
      Parameters:
      logicServerId - the logic server ID
    • setSourceServerId

      public void setSourceServerId(int sourceServerId)
      Description copied from interface: RemoteMessage
      Set the ID of the server that originally created this message.
      Specified by:
      setSourceServerId in interface RemoteMessage
      Parameters:
      sourceServerId - the source server ID
    • setNanoTime

      public void setNanoTime(long nanoTime)
      Description copied from interface: RemoteMessage
      Set the nanosecond timestamp for this message.
      Specified by:
      setNanoTime in interface RemoteMessage
      Parameters:
      nanoTime - the nano time
    • setNetId

      public void setNetId(int netId)
      Description copied from interface: RemoteMessage
      Set the network-level identifier.
      Specified by:
      setNetId in interface RemoteMessage
      Parameters:
      netId - the net ID
    • setData

      public void setData(byte[] data)
      Description copied from interface: RemoteMessage
      Set the serialized payload data.
      Specified by:
      setData in interface RemoteMessage
      Parameters:
      data - the payload byte array
    • setOutputError

      public void setOutputError(ErrorInformation outputError)
      Description copied from interface: RemoteMessage
      Set the error information to be included in the response.
      Specified by:
      setOutputError in interface RemoteMessage
      Parameters:
      outputError - the error information
    • toString

      public String toString()
      Overrides:
      toString in class Object