private void writeObject(WireOut wireOut, String filter, Object obj, byte status){ wireOut.getValueOut().int8(status); wireOut.getValueOut().int64(reactiveJournal.getMessageCounter().incrementAndGet()); wireOut.getValueOut().int64(System.currentTimeMillis()); wireOut.getValueOut().text(filter); if(status== ReactiveStatus.ERROR){ wireOut.getValueOut().throwable((Throwable)obj); }else { wireOut.getValueOut().object(obj); } }
/** * write and exceptions and rolls back if no data was written */ void writeData(boolean isNotComplete, @NotNull Bytes inBytes, @NotNull WriteMarshallable c) { @NotNull final WriteMarshallable marshallable = out -> { final long readPosition = inBytes.readPosition(); final long position = outWire.bytes().writePosition(); try { c.writeMarshallable(outWire); } catch (Throwable t) { inBytes.readPosition(readPosition); if (LOG.isInfoEnabled()) LOG.info("While reading " + inBytes.toDebugString(), " processing wire " + c, t); outWire.bytes().writePosition(position); outWire.writeEventName(() -> "exception").throwable(t); } // write 'reply : {} ' if no data was sent if (position == outWire.bytes().writePosition()) { outWire.writeEventName(reply).marshallable(EMPTY); } }; if (isNotComplete) outWire.writeNotCompleteDocument(false, marshallable); else outWire.writeDocument(false, marshallable); logYaml(); }
/** * write and exceptions and rolls back if no data was written */ void writeData(@NotNull WireIn wireIn, @NotNull WriteMarshallable c) { @NotNull Bytes inBytes = wireIn.bytes(); outWire.writeDocument(false, out -> { final long readPosition = inBytes.readPosition(); final long position = outWire.bytes().writePosition(); try { c.writeMarshallable(outWire); } catch (Throwable t) { final String readingYaml = wireIn.readingPeekYaml(); inBytes.readPosition(readPosition); if (LOG.isInfoEnabled()) LOG.info("While readingBytes=" + inBytes.toDebugString() + "\nreadingYaml=" + readingYaml, "\nprocessing wire " + c, t); outWire.bytes().writePosition(position); outWire.writeEventName(() -> "readingYaml").text(readingYaml); outWire.writeEventName(() -> "exception").throwable(t); } // write 'reply : {} ' if no data was sent if (position == outWire.bytes().writePosition()) { outWire.writeEventName(reply).marshallable(EMPTY); } }); logYaml(); }
outWire.bytes().writePosition(startWritePosition); outWire.writeDocument(true, w -> w.writeEventName(CoreFields.tid).int64(tid)); outWire.writeDocument(false, out -> out.writeEventName(() -> "exception").throwable(e)); logYamlToStandardOut(outWire); rethrow(e);