How many bytes is taken by the payload header. Header is defined here as protocol definition +
length. Most common value here is four bytes, so we keep that as default. Effectively, this is
how much of the message you "don't" want to read from the message's total length with readAll.
Reads a fixed-length string from the saved stream. The string still needs to be
null-terminated, but the read is more efficient, as we can read the entire string in one go
instead of continuously checking for a null-terminator.
Reads a null-terminated string from a DataInputStream. Note that though existing
solutions for this exist, they are either not keyed exactly for our use case, or would lead to
a more combersome addition to this codebase. Also note the 128 byte length is chosen from
profiling and determining that it exceeds the 90th percentile size for inbound messages.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class WireMessage (0.27.1)\n\nVersion latestkeyboard_arrow_down\n\n- [0.27.1 (latest)](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.27.0](/java/docs/reference/pgadapter/0.27.0/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.26.0](/java/docs/reference/pgadapter/0.26.0/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.25.0](/java/docs/reference/pgadapter/0.25.0/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.24.0](/java/docs/reference/pgadapter/0.24.0/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.23.1](/java/docs/reference/pgadapter/0.23.1/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.22.1](/java/docs/reference/pgadapter/0.22.1/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.21.0](/java/docs/reference/pgadapter/0.21.0/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.20.0](/java/docs/reference/pgadapter/0.20.0/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.19.1](/java/docs/reference/pgadapter/0.19.1/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.18.4](/java/docs/reference/pgadapter/0.18.4/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.17.0](/java/docs/reference/pgadapter/0.17.0/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.16.0](/java/docs/reference/pgadapter/0.16.0/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.15.0](/java/docs/reference/pgadapter/0.15.0/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.14.1](/java/docs/reference/pgadapter/0.14.1/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.9.0](/java/docs/reference/pgadapter/0.9.0/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.8.0](/java/docs/reference/pgadapter/0.8.0/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.7.0](/java/docs/reference/pgadapter/0.7.0/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.6.1](/java/docs/reference/pgadapter/0.6.1/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage)\n- [0.5.1](/java/docs/reference/pgadapter/0.5.1/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage) \n\n public abstract class WireMessage\n\nGeneric representation for a wire message, generally executed by calling send. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e WireMessage \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Methods\n--------------\n\n### getParameters(DataInputStream input)\n\n protected static byte[][] getParameters(DataInputStream input)\n\nExtracts parameters/arguments from the user input.\n\nConstructors\n------------\n\n### WireMessage(ConnectionHandler connection, int length)\n\n public WireMessage(ConnectionHandler connection, int length)\n\nFields\n------\n\n### connection\n\n protected ConnectionHandler connection\n\n### inputStream\n\n protected DataInputStream inputStream\n\n### length\n\n protected int length\n\n### outputStream\n\n protected DataOutputStream outputStream\n\nMethods\n-------\n\n### getHeaderLength()\n\n protected int getHeaderLength()\n\nHow many bytes is taken by the payload header. Header is defined here as protocol definition +\nlength. Most common value here is four bytes, so we keep that as default. Effectively, this is\nhow much of the message you \"don't\" want to read from the message's total length with readAll.\n\n### getIdentifier()\n\n public abstract String getIdentifier()\n\nUsed for logging.\n\n### getMessageName()\n\n protected abstract String getMessageName()\n\nUsed for logging.\n\n### getPayloadString()\n\n protected abstract String getPayloadString()\n\nUsed for logging.\n\n### nextHandler()\n\n public void nextHandler()\n\nSome messages may have some more context and require some order. This handles state machine\nsetting for [ConnectionHandler](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.ConnectionHandler).\n\n### read(int length)\n\n public String read(int length)\n\nReads a fixed-length string from the saved stream. The string still needs to be\nnull-terminated, but the read is more efficient, as we can read the entire string in one go\ninstead of continuously checking for a null-terminator.\n\n### readAll()\n\n protected String readAll()\n\nRead the remainder of the received message. To be called once metadata for the message is read.\nMetadata is designated as type, length, etc.\n\n### readString()\n\n public String readString()\n\nReads a null-terminated string from a [DataInputStream](https://docs.oracle.com/javase/8/docs/api/java/io/DataInputStream.html). Note that though existing\nsolutions for this exist, they are either not keyed exactly for our use case, or would lead to\na more combersome addition to this codebase. Also note the 128 byte length is chosen from\nprofiling and determining that it exceeds the 90th percentile size for inbound messages.\n\n### send()\n\n public void send()\n\nOnce the message is ready, call this to send it across the wire. Effectively a template\npattern.\n\n### sendPayload()\n\n protected abstract void sendPayload()\n\nOverride this method to include post-processing and metadata in the sending process. Template\nmethod for send.\n\n### toString()\n\n public String toString()\n\n**Overrides** \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)"]]