Event Hubs Size Limits
- Basic: 256k
- Standard: 1MB
- Dedicatd: 1MB
Service Bus Size Limits
- Basic: 256k
- Standard: 1MB
When the message is received, the transport layer creates an AmqpMessage
instance to hold it. During creation, the incoming stream of bytes is moved to a location appropriate for slicing into multiple ReadOnlySpan<byte>
views. The bytes are scanned once, with the boundaries for each section understood so that each may be represented for a slice to allow named access.
Each section is not processed eagerly, instead waiting for an active requeest to read. When a reader wishes to process a section, it does so by walking each member of a section in a manner similar to enumerating a sequence. Each member is represented by a symbol that corresponds to it's Name
, a type designation that maps to the AMQP type system, and a stream of bytes that represents its value. Using the Name
, a reader can determine if there is interest in that member. If so, the reader can use the Type
to understand how it should be read/translated into a .NET type, following the approach used in the AmqpReader
of the parser prototype.
Once the member is processed, whether the reader was interested in it or not, calling MoveNext
will advance past the type and value, arriving at the next Name
.
internal EventData Translate(AmqpMessage message)
{
var reader = new AmqpReader();
var eventData = new EventData();
var propertyType = default(Type);
// Translate the properties. The same pattern would apply for the other sections of
// the AMQP Message that are not the body.
while (message.ApplicationProperties.MoveNext())
{
propertyType = TranslateAmqpType(message.ApplicationProperties.Type);
reader.Reset(message.ApplicationProperties.Bytes);
eventData.Properties.Add(message.ApplicationPrperties.Name, reader.Read(propertyType));
}
}
// Stubs for helper methods...
internal Type TranslateAmqpType(AmqpType type) => throw new FigureThisOutException();
struct AmqpMessage
{
public TypeMap Header { get; }
public TypeMap DeliveryAnnotations { get; }
public TypeMap MessageAnnotations { get; }
public TypeMap MessageProperties { get; }
public TypeMap ApplicationProperties { get; }
public TypeMap Footer { get; }
public BodyType BodyType { get; }
public ReadOnlySpan<byte> Body { get; }
}
enum BodyType
{
Data,
Value,
Sequence
}
struct TypeMap
{
public ReadOnlySpan<byte> Key { get; private set; }
public AmqpType Type { get; private set; }
public ReadOnlySpan<byte> Bytes{ get; }
public bool MoveNext();
public string ReadKeyName();
}