Search in sources :

Example 1 with BoltRequestMessageWriterV4

use of org.neo4j.bolt.v4.BoltRequestMessageWriterV4 in project neo4j by neo4j.

the class MessageConditions method serialize.

public static byte[] serialize(Neo4jPack neo4jPack, RequestMessage... messages) throws IOException {
    RecordingByteChannel rawData = new RecordingByteChannel();
    Neo4jPack.Packer packer = neo4jPack.newPacker(new BufferedChannelOutput(rawData));
    BoltRequestMessageWriter writer = new BoltRequestMessageWriterV4(packer);
    for (RequestMessage message : messages) {
        writer.write(message);
    }
    writer.flush();
    return rawData.getBytes();
}
Also used : RequestMessage(org.neo4j.bolt.messaging.RequestMessage) RecordingByteChannel(org.neo4j.bolt.messaging.RecordingByteChannel) BoltRequestMessageWriter(org.neo4j.bolt.messaging.BoltRequestMessageWriter) BoltRequestMessageWriterV4(org.neo4j.bolt.v4.BoltRequestMessageWriterV4) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) BufferedChannelOutput(org.neo4j.bolt.packstream.BufferedChannelOutput)

Example 2 with BoltRequestMessageWriterV4

use of org.neo4j.bolt.v4.BoltRequestMessageWriterV4 in project neo4j by neo4j.

the class FragmentedMessageDeliveryTest method serialize.

private byte[] serialize(int chunkSize, RequestMessage... msgs) throws IOException {
    byte[][] serialized = new byte[msgs.length][];
    for (int i = 0; i < msgs.length; i++) {
        RecordingByteChannel channel = new RecordingByteChannel();
        BoltRequestMessageWriter writer = new BoltRequestMessageWriterV4(new Neo4jPackV2().newPacker(new BufferedChannelOutput(channel)));
        writer.write(msgs[i]).flush();
        serialized[i] = channel.getBytes();
    }
    return Chunker.chunk(chunkSize, serialized);
}
Also used : RecordingByteChannel(org.neo4j.bolt.messaging.RecordingByteChannel) BoltRequestMessageWriter(org.neo4j.bolt.messaging.BoltRequestMessageWriter) BoltRequestMessageWriterV4(org.neo4j.bolt.v4.BoltRequestMessageWriterV4)

Aggregations

BoltRequestMessageWriter (org.neo4j.bolt.messaging.BoltRequestMessageWriter)2 RecordingByteChannel (org.neo4j.bolt.messaging.RecordingByteChannel)2 BoltRequestMessageWriterV4 (org.neo4j.bolt.v4.BoltRequestMessageWriterV4)2 RequestMessage (org.neo4j.bolt.messaging.RequestMessage)1 BufferedChannelOutput (org.neo4j.bolt.packstream.BufferedChannelOutput)1 Neo4jPack (org.neo4j.bolt.packstream.Neo4jPack)1