Search in sources :

Example 1 with BoltResponseMessageWriterV3

use of org.neo4j.bolt.v3.messaging.BoltResponseMessageWriterV3 in project neo4j by neo4j.

the class BoltResponseMessageTest method serializeAndDeserialize.

private <T extends ResponseMessage> T serializeAndDeserialize(T msg) throws IOException {
    RecordingByteChannel channel = new RecordingByteChannel();
    BoltResponseMessageReader reader = new BoltResponseMessageReader(neo4jPack.newUnpacker(new BufferedChannelInput(16).reset(channel)));
    BufferedChannelOutput output = new BufferedChannelOutput(channel);
    BoltResponseMessageWriterV3 writer = new BoltResponseMessageWriterV3(neo4jPack::newPacker, output, NullLogService.getInstance());
    writer.write(msg);
    writer.flush();
    channel.eof();
    return unpack(reader, channel);
}
Also used : BufferedChannelInput(org.neo4j.bolt.packstream.BufferedChannelInput) BoltResponseMessageWriterV3(org.neo4j.bolt.v3.messaging.BoltResponseMessageWriterV3) BufferedChannelOutput(org.neo4j.bolt.packstream.BufferedChannelOutput)

Example 2 with BoltResponseMessageWriterV3

use of org.neo4j.bolt.v3.messaging.BoltResponseMessageWriterV3 in project neo4j by neo4j.

the class MessageConditions method serialize.

public static byte[] serialize(Neo4jPack neo4jPack, ResponseMessage... messages) throws IOException {
    RecordingByteChannel rawData = new RecordingByteChannel();
    BufferedChannelOutput output = new BufferedChannelOutput(rawData);
    BoltResponseMessageWriter writer = new BoltResponseMessageWriterV3(neo4jPack::newPacker, output, NullLogService.getInstance());
    for (ResponseMessage message : messages) {
        writer.write(message);
    }
    writer.flush();
    return rawData.getBytes();
}
Also used : BoltResponseMessageWriter(org.neo4j.bolt.messaging.BoltResponseMessageWriter) BoltResponseMessageWriterV3(org.neo4j.bolt.v3.messaging.BoltResponseMessageWriterV3) RecordingByteChannel(org.neo4j.bolt.messaging.RecordingByteChannel) ResponseMessage(org.neo4j.bolt.messaging.ResponseMessage) BufferedChannelOutput(org.neo4j.bolt.packstream.BufferedChannelOutput)

Aggregations

BufferedChannelOutput (org.neo4j.bolt.packstream.BufferedChannelOutput)2 BoltResponseMessageWriterV3 (org.neo4j.bolt.v3.messaging.BoltResponseMessageWriterV3)2 BoltResponseMessageWriter (org.neo4j.bolt.messaging.BoltResponseMessageWriter)1 RecordingByteChannel (org.neo4j.bolt.messaging.RecordingByteChannel)1 ResponseMessage (org.neo4j.bolt.messaging.ResponseMessage)1 BufferedChannelInput (org.neo4j.bolt.packstream.BufferedChannelInput)1