Skip to content

Commit

Permalink
v0.6.1 - Add SubjectMapping header; fix MessageType header
Browse files Browse the repository at this point in the history
  • Loading branch information
rickdotnet committed Nov 17, 2024
1 parent 33081af commit 81595cb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build/version.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<VersionMajor>0</VersionMajor>
<VersionMinor>6</VersionMinor>
<VersionPatch>0</VersionPatch>
<VersionPatch>1</VersionPatch>
<VersionQuality />
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)$(VersionQuality)</VersionPrefix>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Apollo.Providers.NATS/NatsCoreSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task Subscribe(CancellationToken cancellationToken)
{
// type mapping is for endpoint types only
var subjectMapping = "";
if (msg.Headers != null && msg.Headers.TryGetValue(ApolloHeader.MessageType, out var apolloType))
if (msg.Headers != null && msg.Headers.TryGetValue(ApolloHeader.SubjectMapping, out var apolloType))
subjectMapping = apolloType.First() ?? "";

if (handlerOnly || subjectTypeMapping.ContainsKey(subjectMapping))
Expand Down Expand Up @@ -83,7 +83,7 @@ Task ProcessMessage(NatsMsg<byte[]> natsMsg)
Data = natsMsg.Data,

Check warning on line 83 in src/Apollo.Providers.NATS/NatsCoreSubscription.cs

View workflow job for this annotation

GitHub Actions / generate_docs

Possible null reference argument for parameter 'data' in 'ApolloData.implicit operator ApolloData(byte[] data)'.

Check warning on line 83 in src/Apollo.Providers.NATS/NatsCoreSubscription.cs

View workflow job for this annotation

GitHub Actions / generate_docs

Possible null reference argument for parameter 'data' in 'ApolloData.implicit operator ApolloData(byte[] data)'.

Check warning on line 83 in src/Apollo.Providers.NATS/NatsCoreSubscription.cs

View workflow job for this annotation

GitHub Actions / generate_docs

Possible null reference argument for parameter 'data' in 'ApolloData.implicit operator ApolloData(byte[] data)'.

Check warning on line 83 in src/Apollo.Providers.NATS/NatsCoreSubscription.cs

View workflow job for this annotation

GitHub Actions / generate_docs

Possible null reference argument for parameter 'data' in 'ApolloData.implicit operator ApolloData(byte[] data)'.

Check warning on line 83 in src/Apollo.Providers.NATS/NatsCoreSubscription.cs

View workflow job for this annotation

GitHub Actions / publish

Possible null reference argument for parameter 'data' in 'ApolloData.implicit operator ApolloData(byte[] data)'.

Check warning on line 83 in src/Apollo.Providers.NATS/NatsCoreSubscription.cs

View workflow job for this annotation

GitHub Actions / publish

Possible null reference argument for parameter 'data' in 'ApolloData.implicit operator ApolloData(byte[] data)'.

Check warning on line 83 in src/Apollo.Providers.NATS/NatsCoreSubscription.cs

View workflow job for this annotation

GitHub Actions / publish

Possible null reference argument for parameter 'data' in 'ApolloData.implicit operator ApolloData(byte[] data)'.

Check warning on line 83 in src/Apollo.Providers.NATS/NatsCoreSubscription.cs

View workflow job for this annotation

GitHub Actions / publish

Possible null reference argument for parameter 'data' in 'ApolloData.implicit operator ApolloData(byte[] data)'.
};

if (message.Headers.TryGetValue(ApolloHeader.MessageType, out var headerType)
if (message.Headers.TryGetValue(ApolloHeader.SubjectMapping, out var headerType)
&& headerType.Count > 0)
{
message.MessageType =
Expand Down
4 changes: 2 additions & 2 deletions src/Apollo.Providers.NATS/NatsJetStreamSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ await js.CreateStreamAsync(
try
{
var subjectMapping = "";
if (msg.Headers != null && msg.Headers.TryGetValue(ApolloHeader.MessageType, out var apolloType))
if (msg.Headers != null && msg.Headers.TryGetValue(ApolloHeader.SubjectMapping, out var apolloType))
subjectMapping = apolloType.First() ?? "";

if (handlerOnly || subjectTypeMapping.ContainsKey(subjectMapping))
Expand Down Expand Up @@ -118,7 +118,7 @@ Task ProcessMessage(NatsJSMsg<byte[]> natsMsg)
};

var subjectMapping = "";
if (natsMsg.Headers != null && natsMsg.Headers.TryGetValue(ApolloHeader.MessageType, out var apolloType))
if (natsMsg.Headers != null && natsMsg.Headers.TryGetValue(ApolloHeader.SubjectMapping, out var apolloType))
subjectMapping = apolloType.First() ?? "";

subjectTypeMapping.TryGetValue(subjectMapping, out var messageType);
Expand Down
1 change: 1 addition & 0 deletions src/Apollo/ApolloHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace Apollo;

public static class ApolloHeader
{
public const string SubjectMapping = "apollo-subject-mapping";
public const string MessageType = "apollo-message-type";
public const string MessageClrType = "apollo-message-clr-type";
public const string MessageAction = "apollo-message-action";
Expand Down
7 changes: 4 additions & 3 deletions src/Apollo/Internal/DefaultPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ private ApolloMessage CreateApolloMessage<TMessage>(TMessage message, string act
MessageType = messageType,
Headers = new Dictionary<string, StringValues>
{
{ApolloHeader.MessageType, subjectTypeMapper.ApolloMessageType(messageType.Name)},
{ApolloHeader.MessageClrType, messageType.AssemblyQualifiedName!},
{ApolloHeader.MessageAction, action}
[ApolloHeader.MessageType] = messageType.Name,
[ApolloHeader.SubjectMapping] = subjectTypeMapper.ApolloMessageType(messageType.Name),
[ApolloHeader.MessageClrType] = messageType.AssemblyQualifiedName!,
[ApolloHeader.MessageAction] = action
}
};
}
Expand Down

0 comments on commit 81595cb

Please sign in to comment.