public String getRoutingKey() throws IOException { if (routingKeySize < 0) throw new IllegalStateException("Routing key already read"); input.read(routingKeyBuf, 0, routingKeySize); String ans = new String(routingKeyBuf, 0, routingKeySize, UTF8); routingKeySize = -1; return ans; }
public byte[] getPayload() throws IOException { if (payloadSize < 0) throw new IllegalStateException("Payload already read"); if (routingKeySize > 0) { input.skip(routingKeySize); // routing key was never read routingKeySize = -1; } byte[] buf = new byte[payloadSize]; input.read(buf, 0, payloadSize); payloadSize = -1; return buf; }