After moving the type mapper to be an interface, a custom mapper can be used almost everywhere.
The only place where the default static type mapper instance is used is producer extensions. Those extensions are useful as they hide serialisation boilerplate, but there's an issue with having MessageType in ProducedMessage record. The property is used by BaseProducer for diagnostics, but the actual message type used in produce actions is provided by the serialiser. Therefore, there is a chance of using different message types in diagnostics and in the actual produced message, which can lead to issues when finding issues in production.
The solution would be:
Serialisation is handled by BaseProducer
ProducedMessage record would not have MessageType property
Split ProducedMessage (input) and internal produced message (serialised payload and event type)
After moving the type mapper to be an interface, a custom mapper can be used almost everywhere.
The only place where the default static type mapper instance is used is producer extensions. Those extensions are useful as they hide serialisation boilerplate, but there's an issue with having
MessageType
inProducedMessage
record. The property is used byBaseProducer
for diagnostics, but the actual message type used in produce actions is provided by the serialiser. Therefore, there is a chance of using different message types in diagnostics and in the actual produced message, which can lead to issues when finding issues in production.The solution would be:
BaseProducer
ProducedMessage
record would not haveMessageType
propertyProducedMessage
(input) and internal produced message (serialised payload and event type)