in Source/Tx.Bond/BinaryEventSource.cs [306:363]
private void WriteInternal(
DateTime occurenceTime,
DateTime receiveTime,
string inputProtocol,
string source,
string manifestId,
byte[] eventPayload)
{
// Maximum record size is 64K for both system and user data, so counting 88 bytes for system data here as well
var maxPayloadSize = MaxPayloadSize - (manifestId.Length + source.Length + inputProtocol.Length) * 2;
if (maxPayloadSize <= 0)
{
throw new ArgumentOutOfRangeException();
}
var occurenceFileTimeUtc = occurenceTime.ToFileTimeUtc();
var receiveFileTimeUtc = receiveTime.ToFileTimeUtc();
if (eventPayload.Length <= maxPayloadSize)
{
this.WriteBinaryPayload(
occurenceFileTimeUtc,
receiveFileTimeUtc,
inputProtocol,
source,
manifestId,
unchecked((uint)(eventPayload.Length)),
eventPayload);
}
else
{
// User data for chunked event is 12 bytes greather than non-chunked event
maxPayloadSize -= 12;
var chunks = eventPayload.Split(maxPayloadSize);
lock (this.writeChuckedBinaryPayloadGuard)
{
var packageId = unchecked(this.currentPackageId++);
for (uint i = 0; i < chunks.Length; i++)
{
this.WriteChunkedBinaryPayload(
packageId,
occurenceFileTimeUtc,
receiveFileTimeUtc,
inputProtocol,
source,
manifestId,
unchecked((uint)(chunks.Length)),
i,
unchecked((uint)(chunks[i].Length)),
chunks[i]);
}
}
}
}