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 mutators


Message mutators provide the ability to modify a message either on the way in or out of a message handler. There are two different categories of message mutators: applicative and transport message mutators.

An applicative message mutator is used to act on individual messages. They are the ideal place to perform tasks such as validation. Access to a message is provided as an object, so usually some amount of reflection is required to implement anything of substance. There are three possible interfaces to implement to create an applicative message mutator:

  • Implement IMutateOutgoingMessages to manipulate messages being sent from the endpoint

  • Implement IMutateIncomingMessages to manipulate messages being received by the endpoint

  • Implement IMessageMutator, which itself implements both the previously mentioned interfaces, to manipulate both incoming and outgoing messages

A transport message mutator is used to act on transport messages, which contain the message serialized to a byte...