Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public CustomTopicAttribute(string pubsubName, string name)
/// <inheritdoc/>
public string Name { get; }

/// <inheritdoc/>
public string DeadLetterTopicName { get; }

/// <inheritdoc/>
public new string Match { get; }

Expand Down
6 changes: 4 additions & 2 deletions src/Dapr.AspNetCore/DaprEndpointRouteBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static IEndpointConventionBuilder CreateSubscribeEndPoint(IEndpointRoute
var topicMetadata = e.Metadata.GetOrderedMetadata<ITopicMetadata>();
var originalTopicMetadata = e.Metadata.GetOrderedMetadata<IOriginalTopicMetadata>();

var subs = new List<(string PubsubName, string Name, bool? EnableRawPayload, string Match, int Priority, Dictionary<string, string[]> OriginalTopicMetadata, string MetadataSeparator, RoutePattern RoutePattern)>();
var subs = new List<(string PubsubName, string Name, bool? EnableRawPayload, string Match, int Priority, Dictionary<string, string[]> OriginalTopicMetadata, string MetadataSeparator, RoutePattern RoutePattern, string DeadLetterTopicName)>();

for (int i = 0; i < topicMetadata.Count(); i++)
{
Expand All @@ -85,7 +85,8 @@ private static IEndpointConventionBuilder CreateSubscribeEndPoint(IEndpointRoute
.GroupBy(c => c.Name)
.ToDictionary(m => m.Key, m => m.Select(c => c.Value).Distinct().ToArray()),
(topicMetadata[i] as IOwnedOriginalTopicMetadata)?.MetadataSeparator,
e.RoutePattern));
e.RoutePattern,
topicMetadata[i].DeadLetterTopicName));
}

return subs;
Expand Down Expand Up @@ -131,6 +132,7 @@ private static IEndpointConventionBuilder CreateSubscribeEndPoint(IEndpointRoute
Topic = first.Name,
PubsubName = first.PubsubName,
Metadata = metadata.Count > 0 ? metadata : null,
DeadLetterTopic = first.DeadLetterTopicName
};

// Use the V2 routing rules structure
Expand Down
5 changes: 5 additions & 0 deletions src/Dapr.AspNetCore/ITopicMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public interface ITopicMetadata
/// </summary>
string Name { get; }

/// <summary>
/// Gets the dead letter topic name
/// </summary>
string DeadLetterTopicName { get; }

/// <summary>
/// Gets the pubsub component name name.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Dapr.AspNetCore/Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ internal class Subscription
/// </summary>
public string Topic { get; set; }

/// <summary>
/// Gets or sets the dead letter topic name.
/// </summary>
public string DeadLetterTopic { get; set; }

/// <summary>
/// Gets or sets the pubsub name
/// </summary>
Expand Down
19 changes: 15 additions & 4 deletions src/Dapr.AspNetCore/TopicAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class TopicAttribute : Attribute, ITopicMetadata, IRawTopicMetadata, IOwn
/// <param name="name">The topic name.</param>
/// <param name="ownedMetadatas">The topic owned metadata ids.</param>
/// <param name="metadataSeparator">Separator to use for metadata.</param>
public TopicAttribute(string pubsubName, string name, string[] ownedMetadatas = null, string metadataSeparator = null)
/// <param name="deadLetterTopicName">The dead letter topic name.</param>
public TopicAttribute(string pubsubName, string name, string[] ownedMetadatas = null, string metadataSeparator = null, string deadLetterTopicName = null)
{
ArgumentVerifier.ThrowIfNullOrEmpty(pubsubName, nameof(pubsubName));
ArgumentVerifier.ThrowIfNullOrEmpty(name, nameof(name));
Expand All @@ -37,6 +38,7 @@ public TopicAttribute(string pubsubName, string name, string[] ownedMetadatas =
this.PubsubName = pubsubName;
this.OwnedMetadatas = ownedMetadatas;
this.MetadataSeparator = metadataSeparator;
this.DeadLetterTopicName = deadLetterTopicName;
}

/// <summary>
Expand All @@ -47,7 +49,8 @@ public TopicAttribute(string pubsubName, string name, string[] ownedMetadatas =
/// <param name="enableRawPayload">The enable/disable raw pay load flag.</param>
/// <param name="ownedMetadatas">The topic owned metadata ids.</param>
/// <param name="metadataSeparator">Separator to use for metadata.</param>
public TopicAttribute(string pubsubName, string name, bool enableRawPayload, string[] ownedMetadatas = null, string metadataSeparator = null)
/// <param name="deadLetterTopicName">The dead letter topic name.</param>
public TopicAttribute(string pubsubName, string name, bool enableRawPayload, string[] ownedMetadatas = null, string metadataSeparator = null, string deadLetterTopicName = null)
{
ArgumentVerifier.ThrowIfNullOrEmpty(pubsubName, nameof(pubsubName));
ArgumentVerifier.ThrowIfNullOrEmpty(name, nameof(name));
Expand All @@ -57,6 +60,7 @@ public TopicAttribute(string pubsubName, string name, bool enableRawPayload, str
this.EnableRawPayload = enableRawPayload;
this.OwnedMetadatas = ownedMetadatas;
this.MetadataSeparator = metadataSeparator;
this.DeadLetterTopicName = deadLetterTopicName;
}

/// <summary>
Expand All @@ -68,7 +72,8 @@ public TopicAttribute(string pubsubName, string name, bool enableRawPayload, str
/// <param name="priority">The priority of the rule (low-to-high values).</param>
/// <param name="ownedMetadatas">The topic owned metadata ids.</param>
/// <param name="metadataSeparator">Separator to use for metadata.</param>
public TopicAttribute(string pubsubName, string name, string match, int priority, string[] ownedMetadatas = null, string metadataSeparator = null)
/// <param name="deadLetterTopicName">The dead letter topic name.</param>
public TopicAttribute(string pubsubName, string name, string match, int priority, string[] ownedMetadatas = null, string metadataSeparator = null, string deadLetterTopicName = null)
{
ArgumentVerifier.ThrowIfNullOrEmpty(pubsubName, nameof(pubsubName));
ArgumentVerifier.ThrowIfNullOrEmpty(name, nameof(name));
Expand All @@ -79,6 +84,7 @@ public TopicAttribute(string pubsubName, string name, string match, int priority
this.Priority = priority;
this.OwnedMetadatas = ownedMetadatas;
this.MetadataSeparator = metadataSeparator;
this.DeadLetterTopicName = deadLetterTopicName;
}

/// <summary>
Expand All @@ -91,7 +97,8 @@ public TopicAttribute(string pubsubName, string name, string match, int priority
/// <param name="priority">The priority of the rule (low-to-high values).</param>
/// <param name="ownedMetadatas">The topic owned metadata ids.</param>
/// <param name="metadataSeparator">Separator to use for metadata.</param>
public TopicAttribute(string pubsubName, string name, bool enableRawPayload, string match, int priority, string[] ownedMetadatas = null, string metadataSeparator = null)
/// <param name="deadLetterTopicName">The dead letter topic name.</param>
public TopicAttribute(string pubsubName, string name, bool enableRawPayload, string match, int priority, string[] ownedMetadatas = null, string metadataSeparator = null, string deadLetterTopicName = null)
{
ArgumentVerifier.ThrowIfNullOrEmpty(pubsubName, nameof(pubsubName));
ArgumentVerifier.ThrowIfNullOrEmpty(name, nameof(name));
Expand All @@ -103,11 +110,15 @@ public TopicAttribute(string pubsubName, string name, bool enableRawPayload, str
this.Priority = priority;
this.OwnedMetadatas = ownedMetadatas;
this.MetadataSeparator = metadataSeparator;
this.DeadLetterTopicName = deadLetterTopicName;
}

/// <inheritdoc/>
public string Name { get; }

/// <inheritdoc/>
public string DeadLetterTopicName { get; }

/// <inheritdoc/>
public string PubsubName { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public CustomTopicAttribute(string pubsubName, string name)

public string Name { get; }

public string DeadLetterTopicName { get; }

public string PubsubName { get; }

public new string Match { get; }
Expand Down