@Override public void consume(Message message) { try { String content = jsonHandler.serialize(message); byte[] contentBytes = content.getBytes(encoding); int contentLength = contentBytes.length; String header = getHeader(contentLength); byte[] headerBytes = header.getBytes(StandardCharsets.US_ASCII); synchronized (outputLock) { output.write(headerBytes); output.write(contentBytes); output.flush(); } } catch (IOException exception) { throw new JsonRpcException(exception); } }
@Override public void consume(Message message) { try { String content = jsonHandler.serialize(message); byte[] contentBytes = content.getBytes(encoding); int contentLength = contentBytes.length; String header = getHeader(contentLength); byte[] headerBytes = header.getBytes(StandardCharsets.US_ASCII); synchronized (outputLock) { output.write(headerBytes); output.write(contentBytes); output.flush(); } } catch (IOException exception) { throw new JsonRpcException(exception); } }