Bond Serializer

Project Hosting | Nuget: NServiceBus.Bond (Version: 1.x) | License
This is a community run project. License and support are independent of Particular Software.
Target NServiceBus Version: 6.x

Serializes messages with Microsoft Bond.

Bond is a cross-platform framework for working with schematized data. It supports cross-language de/serialization and powerful generic mechanisms for efficiently manipulating data. Bond is broadly used at Microsoft in high scale services.

Usage

Edit
endpointConfiguration.UseSerialization<BondSerializer>();

This serializer does not support Messages defined as Interfaces. Instead use a public class with the same contract as the interface. The class can optionally implement any required interfaces.

If an explicit interface is send an exception will be thrown with the following message:

Interface based message are not supported. 
Create a class that implements the desired interface

SerializationDelegates

Customizes the cached delegates that serialize and deserialize message types. This is an optional setting.

The default serialization delegates are as follows.

Edit
var serialization = endpointConfiguration.UseSerialization<BondSerializer>();
serialization.SerializationDelegates(
    sertializationDelegatesBuilder: messageType =>
    {
        return new SertializationDelegates(
            serialize: (buffer, message) =>
            {
                var writer = new CompactBinaryWriter<OutputBuffer>(buffer);
                var serializer = new Serializer<CompactBinaryWriter<OutputBuffer>>(messageType);
                serializer.Serialize(message, writer);
            },
            deserialize: buffer =>
            {
                var reader = new CompactBinaryReader<InputBuffer>(buffer);
                var deserializer = new Deserializer<CompactBinaryReader<InputBuffer>>(messageType);
                return deserializer.Deserialize(reader);
            });
    });

Custom Content Key

When using additional deserializers or transitioning between different versions of the same serializer it can be helpful to take explicit control over the content type a serializer passes to NServiceBus (to be used for the ContentType header).

Edit
var serialization = endpointConfiguration.UseSerialization<BondSerializer>();
serialization.ContentTypeKey("custom-key");

Samples


Last modified