Book Image

Learning NServiceBus - Second Edition

By : David Boike
Book Image

Learning NServiceBus - Second Edition

By: David Boike

Overview of this book

Table of Contents (18 chapters)
Learning NServiceBus Second Edition
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Message serialization


As we have already seen, our NServiceBus messages are plain old C# classes or interfaces, but these must be serialized in some way so that they can be transmitted using the underlying queuing infrastructure.

The default choice for a message serializer is XML, which requires no configuration whatsoever, unless you want to set some advanced options on the serializer itself. However, NServiceBus also supports JSON, BSON, and Binary serialization out of the box:

cfg.UseSerialization<XmlSerializer>();
cfg.UseSerialization<JsonSerializer>();
cfg.UseSerialization<BsonSerializer>();
cfg.UseSerialization<BinarySerializer>();

Like the persistence configuration options, the serializers expose various settings through extension methods, although none are important enough to mention here.

While XML serialization is the default serialization in NServiceBus 5.0 (and in all previous versions), this will not always be the case. The plan for future versions of NServiceBus...