Class DefaultMessageMapper
Default message mapper that copies context properties between transports.
public class DefaultMessageMapper : IMessageMapper
- Inheritance
-
DefaultMessageMapper
- Implements
- Derived
- Inherited Members
- Extension Methods
Remarks
This mapper provides basic property copying between transport contexts. It preserves all common properties (MessageId, CorrelationId, etc.) and allows transport-specific properties to be mapped via configuration.
Constructors
DefaultMessageMapper(string, string, string)
Initializes a new instance of the DefaultMessageMapper class.
public DefaultMessageMapper(string name, string sourceTransport = "*", string targetTransport = "*")
Parameters
namestringThe mapper name.
sourceTransportstringThe source transport (or "*" for any).
targetTransportstringThe target transport (or "*" for any).
Fields
WildcardTransport
Gets the wildcard transport identifier for matching any transport.
public const string WildcardTransport = "*"
Field Value
Properties
Name
Gets the name of this mapper for registration and logging purposes.
public string Name { get; }
Property Value
- string
A unique name identifying this mapper.
SourceTransport
Gets the source transport type this mapper handles.
public string SourceTransport { get; }
Property Value
- string
The source transport name (e.g., "rabbitmq", "kafka", "*" for any).
TargetTransport
Gets the target transport type this mapper produces.
public string TargetTransport { get; }
Property Value
- string
The target transport name (e.g., "rabbitmq", "kafka", "*" for any).
Methods
CanMap(string, string)
Determines whether this mapper can handle the specified source and target transports.
public bool CanMap(string sourceTransport, string targetTransport)
Parameters
Returns
CopyTransportProperties(ITransportMessageContext, TransportMessageContext)
Copies transport-specific properties from source to target context.
protected virtual void CopyTransportProperties(ITransportMessageContext source, TransportMessageContext target)
Parameters
sourceITransportMessageContextThe source context.
targetTransportMessageContextThe target context.
Remarks
Override this method to customize how transport properties are copied or transformed.
CreateTargetContext(string, string)
Creates the appropriate target context for the specified transport.
protected virtual TransportMessageContext CreateTargetContext(string messageId, string targetTransport)
Parameters
Returns
- TransportMessageContext
A new transport message context instance.
Map(ITransportMessageContext, string)
Maps a source context to a target context for cross-transport delivery.
public virtual ITransportMessageContext Map(ITransportMessageContext source, string targetTransportName)
Parameters
sourceITransportMessageContextThe source transport message context.
targetTransportNamestringThe name of the target transport.
Returns
- ITransportMessageContext
A new context configured for the target transport.
Exceptions
- ArgumentNullException
Thrown when
sourceis null.- InvalidOperationException
Thrown when the mapper cannot handle the specified transport combination.