Bond Serializer Usage

Component: Bond Serializer
NuGet Package NServiceBus.Bond (2.x)
This is a community maintained project
Target NServiceBus Version: 7.x

Configuring NServiceBus to use Bond

var endpointConfiguration = new EndpointConfiguration("Samples.Serialization.Bond");
endpointConfiguration.UseSerialization<BondSerializer>();

The message class

[Schema]
public class CreateOrder :
    IMessage
{
    [Id(0)]
    public int OrderId { get; set; }

    [Id(1)]
    public long Date { get; set; }

    [Id(2)]
    public int CustomerId { get; set; }
}

Sending a message

The message is decorated with Bond attributes.

var message = new CreateOrder
{
    OrderId = 9,
    Date = DateTime.Now.Ticks,
    CustomerId = 12,
};
await endpointInstance.SendLocal(message)
    .ConfigureAwait(false);

Note that for simplicity, this sample does not use Bond code generation or the Bond.Compiler.CSharp/Bond.CSharp for schema to code generation.

Related Articles

  • Bond Serializer
    Serialization and deserialization with Microsoft Bond using the NServiceBus.Bond community package.
  • Serialization
    Information about how messages are serialized and deserialized on a transport.

Last modified