Message Mappers
Writing A Message Mapper
public class GreetingMadeMessageMapper : IAmAMessageMapper<GreetingMade>
{
public Message MapToMessage(GreetingMade request)
{
var header = new MessageHeader(messageId: request.Id, topic: "GreetingMade", messageType: MessageType.MT_EVENT);
var payload = System.Text.Json.JsonSerializer.Serialize(request, new JsonSerializerOptions(JsonSerializerDefaults.General));
var body = new MessageBody(payload, ApplicationJson, CharacterEncoding.UTF8);
var message = new Message(header, body);
return message;
}
public GreetingMade MapToRequest(Message message)
{
return JsonSerializer.Deserialize<GreetingMade>(message.Body.Value, JsonSerialisationOptions.Options);
}
}Brighter Message Structure
The Message Header
Common Properties
Brighter Properties
Routing
The Message Body
Options for System.Text.Json Serialization
Further Reading
Last updated
Was this helpful?
