Class CommonMessage
java.lang.Object
com.iohao.net.framework.protocol.CommonMessage
- All Implemented Interfaces:
FutureMessage, RemoteMessage
- Direct Known Subclasses:
RequestMessage, ResponseMessage, UserRequestMessage, UserResponseMessage
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 Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected byte[]protected intprotected longprotected intprotected longprotected intprotected ErrorInformationprotected intprotected String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDerive theCmdInforoute descriptor from the merged command key.intGet the merged command route key (cmd + subCmd packed into a single int).byte[]getData()Get the serialized payload data.intGet the ID of the external server that originated or will receive this message.longGet the future correlation id.intGet the ID of the logic server handling this message.longGet the nanosecond timestamp recorded when this message was created or received.intgetNetId()Get the network-level identifier.intGet the ID of the server that originally created this message.Get the distributed trace ID for this message.voidsetCmdInfo(CmdInfo cmdInfo) Set the command route from aCmdInfodescriptor.voidsetCmdMerge(int cmdMerge) Set the merged command route key.voidsetData(byte[] data) Set the serialized payload data.voidsetExternalServerId(int externalServerId) Set the ID of the external server.voidsetFutureId(long futureId) Set the future correlation id.voidsetLogicServerId(int logicServerId) Set the ID of the logic server handling this message.voidsetNanoTime(long nanoTime) Set the nanosecond timestamp for this message.voidsetNetId(int netId) Set the network-level identifier.voidsetOutputError(ErrorInformation outputError) Set the error information to be included in the response.voidsetSourceServerId(int sourceServerId) Set the ID of the server that originally created this message.voidsetTraceId(String traceId) Set the distributed trace ID for this message.toString()
-
Field Details
-
futureId
protected long futureId -
cmdMerge
protected int cmdMerge -
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
-
-
Constructor Details
-
CommonMessage
public CommonMessage()
-
-
Method Details
-
setCmdInfo
Set the command route from aCmdInfodescriptor.- Specified by:
setCmdInfoin interfaceRemoteMessage- Parameters:
cmdInfo- the command info containing the merged route key
-
getCmdInfo
Derive theCmdInforoute descriptor from the merged command key.- Specified by:
getCmdInfoin interfaceRemoteMessage- Returns:
- the command info
-
getFutureId
public long getFutureId()Description copied from interface:FutureMessageGet the future correlation id.- Specified by:
getFutureIdin interfaceFutureMessage- Returns:
- the future id
-
getCmdMerge
public int getCmdMerge()Description copied from interface:RemoteMessageGet the merged command route key (cmd + subCmd packed into a single int).- Specified by:
getCmdMergein interfaceRemoteMessage- Returns:
- the merged command key
-
getTraceId
Description copied from interface:RemoteMessageGet the distributed trace ID for this message.- Specified by:
getTraceIdin interfaceRemoteMessage- Returns:
- the trace ID, or
nullif not set
-
getExternalServerId
public int getExternalServerId()Description copied from interface:RemoteMessageGet the ID of the external server that originated or will receive this message.- Specified by:
getExternalServerIdin interfaceRemoteMessage- Returns:
- the external server ID
-
getLogicServerId
public int getLogicServerId()Description copied from interface:RemoteMessageGet the ID of the logic server handling this message.- Specified by:
getLogicServerIdin interfaceRemoteMessage- Returns:
- the logic server ID
-
getSourceServerId
public int getSourceServerId()Description copied from interface:RemoteMessageGet the ID of the server that originally created this message.- Specified by:
getSourceServerIdin interfaceRemoteMessage- Returns:
- the source server ID
-
getNanoTime
public long getNanoTime()Description copied from interface:RemoteMessageGet the nanosecond timestamp recorded when this message was created or received.- Specified by:
getNanoTimein interfaceRemoteMessage- Returns:
- the nano time
-
getNetId
public int getNetId()Description copied from interface:RemoteMessageGet the network-level identifier.- Specified by:
getNetIdin interfaceRemoteMessage- Returns:
- the net ID
-
getData
public byte[] getData()Description copied from interface:RemoteMessageGet the serialized payload data.- Specified by:
getDatain interfaceRemoteMessage- Returns:
- the payload byte array
-
getOutputError
-
setFutureId
public void setFutureId(long futureId) Description copied from interface:FutureMessageSet the future correlation id.- Specified by:
setFutureIdin interfaceFutureMessage- Parameters:
futureId- the future id
-
setCmdMerge
public void setCmdMerge(int cmdMerge) Description copied from interface:RemoteMessageSet the merged command route key.- Specified by:
setCmdMergein interfaceRemoteMessage- Parameters:
cmdMerge- the merged command key
-
setTraceId
Description copied from interface:RemoteMessageSet the distributed trace ID for this message.- Specified by:
setTraceIdin interfaceRemoteMessage- Parameters:
traceId- the trace ID
-
setExternalServerId
public void setExternalServerId(int externalServerId) Description copied from interface:RemoteMessageSet the ID of the external server.- Specified by:
setExternalServerIdin interfaceRemoteMessage- Parameters:
externalServerId- the external server ID
-
setLogicServerId
public void setLogicServerId(int logicServerId) Description copied from interface:RemoteMessageSet the ID of the logic server handling this message.- Specified by:
setLogicServerIdin interfaceRemoteMessage- Parameters:
logicServerId- the logic server ID
-
setSourceServerId
public void setSourceServerId(int sourceServerId) Description copied from interface:RemoteMessageSet the ID of the server that originally created this message.- Specified by:
setSourceServerIdin interfaceRemoteMessage- Parameters:
sourceServerId- the source server ID
-
setNanoTime
public void setNanoTime(long nanoTime) Description copied from interface:RemoteMessageSet the nanosecond timestamp for this message.- Specified by:
setNanoTimein interfaceRemoteMessage- Parameters:
nanoTime- the nano time
-
setNetId
public void setNetId(int netId) Description copied from interface:RemoteMessageSet the network-level identifier.- Specified by:
setNetIdin interfaceRemoteMessage- Parameters:
netId- the net ID
-
setData
public void setData(byte[] data) Description copied from interface:RemoteMessageSet the serialized payload data.- Specified by:
setDatain interfaceRemoteMessage- Parameters:
data- the payload byte array
-
setOutputError
Description copied from interface:RemoteMessageSet the error information to be included in the response.- Specified by:
setOutputErrorin interfaceRemoteMessage- Parameters:
outputError- the error information
-
toString
-