Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Added parent-id to built in serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy D. Miller authored and Jeremy D. Miller committed Sep 12, 2022
1 parent 1188243 commit e807f55
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public serialization_and_deserialization_of_single_message()
Destination = "durable:https://localhost:2222/incoming".ToUri(),
DeliverBy = DateTime.Today.ToUniversalTime(),
ReplyUri = "durable:https://localhost:2221/replies".ToUri(),
SagaId = Guid.NewGuid().ToString()
SagaId = Guid.NewGuid().ToString(),
ParentId = Guid.NewGuid().ToString()
};

outgoing.Headers.Add("name", "Jeremy");
Expand Down Expand Up @@ -79,6 +80,12 @@ public void brings_over_the_correlation_id()
incoming.Id.ShouldBe(outgoing.Id);
}

[Fact]
public void brings_over_the_parent_id()
{
incoming.ParentId.ShouldBe(outgoing.ParentId);
}

[Fact]
public void brings_over_the_saga_id()
{
Expand Down
6 changes: 6 additions & 0 deletions src/Jasper/Envelope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ public object? Message
/// </summary>
public Uri? Destination { get; set; }

/// <summary>
/// The open telemetry activity parent id. Jasper uses this to correctly correlate connect
/// activity across services
/// </summary>
public string ParentId { get; internal set; }

/// <summary>
/// Specifies the accepted content types for the requested reply
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/Jasper/EnvelopeConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static class EnvelopeConstants
public const string CorrelationIdKey = "correlation-id";
public const string SagaIdKey = "saga-id";
public const string IdKey = "id";
public const string ConversationIdKey = "parent-id";
public const string ConversationIdKey = "conversation-id";
public const string ContentTypeKey = "content-type";
public const string SourceKey = "source";
public const string ReplyRequestedKey = "reply-requested";
Expand All @@ -18,4 +18,5 @@ public static class EnvelopeConstants
public const string MessageTypeKey = "message-type";
public const string AcceptedContentTypesKey = "accepted-content-types";
public const string DeliverByHeader = "deliver-by";
public const string ParentIdKey = "parent-id";
}
5 changes: 5 additions & 0 deletions src/Jasper/Serialization/EnvelopeSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ private static void readData(Envelope env, string key, string value)

break;

case EnvelopeConstants.ParentIdKey:
env.ParentId = value;
break;

case EnvelopeConstants.ReplyRequestedKey:
env.ReplyRequested = value;
break;
Expand Down Expand Up @@ -188,6 +192,7 @@ private static int writeHeaders(BinaryWriter writer, Envelope env)
writer.WriteProp(ref count, EnvelopeConstants.ConversationIdKey, env.ConversationId);
writer.WriteProp(ref count, EnvelopeConstants.DestinationKey, env.Destination);
writer.WriteProp(ref count, EnvelopeConstants.SagaIdKey, env.SagaId);
writer.WriteProp(ref count, EnvelopeConstants.ParentIdKey, env.ParentId);

if (env.AcceptedContentTypes.Any())
{
Expand Down

0 comments on commit e807f55

Please sign in to comment.