Skip to content

Commit

Permalink
Merge pull request #96 from twino-framework/v3
Browse files Browse the repository at this point in the history
3.7.0
  • Loading branch information
mhelvacikoylu committed Aug 23, 2020
2 parents ded9556 + 34bd53d commit 3adf3ba
Show file tree
Hide file tree
Showing 30 changed files with 949 additions and 215 deletions.
1 change: 1 addition & 0 deletions src/Samples/Sample.Route.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Twino.MQ.Data;
using Twino.MQ.Events;
using Twino.MQ.Routing;
using Twino.Protocols.TMQ;
using Twino.Server;

namespace Sample.Route.Server
Expand Down
1 change: 1 addition & 0 deletions src/Samples/Sample.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Twino.MQ.Data;
using Twino.MQ.Queues;
using Twino.MQ.Routing;
using Twino.Protocols.TMQ;
using Twino.Server;

namespace Sample.Server
Expand Down
24 changes: 24 additions & 0 deletions src/Twino.Client.TMQ/Annotations/QueueTagAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;

namespace Twino.Client.TMQ.Annotations
{
/// <summary>
/// Used when queue is created with first push
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class QueueTagAttribute : Attribute
{
/// <summary>
/// The Queue Tag for the type
/// </summary>
public string Tag { get; }

/// <summary>
/// Creates new Queue Tag attribute
/// </summary>
public QueueTagAttribute(string tag)
{
Tag = tag;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public class TypeDeliveryDescriptor
/// </summary>
public MessagingQueueStatus? QueueStatus { get; set; }

/// <summary>
/// If queue is created with a message push and that value is not null, queue will be created with that Tag
/// </summary>
public string Tag { get; set; }

/// <summary>
/// Headers for delivery descriptor of type
/// </summary>
Expand Down Expand Up @@ -157,6 +162,9 @@ public TmqMessage CreateMessage(MessageType type, string overrideTargetName, ush
if (QueueStatus.HasValue)
message.AddHeader(TmqHeaders.QUEUE_STATUS, QueueStatus.Value.ToString().ToLower());

if (!string.IsNullOrEmpty(Tag))
message.AddHeader(TmqHeaders.QUEUE_TAG, Tag);

foreach (KeyValuePair<string, string> pair in Headers)
message.AddHeader(pair.Key, pair.Value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ private void ResolveBase(Type type, TypeDeliveryDescriptor descriptor)
if (qsa != null)
descriptor.QueueStatus = qsa.Status;

QueueTagAttribute qta = type.GetCustomAttribute<QueueTagAttribute>(true);
if (qta != null)
descriptor.Tag = qta.Tag;

IEnumerable<MessageHeaderAttribute> headerAttributes = type.GetCustomAttributes<MessageHeaderAttribute>(true);
foreach (MessageHeaderAttribute headerAttribute in headerAttributes)
descriptor.Headers.Add(new KeyValuePair<string, string>(headerAttribute.Key, headerAttribute.Value));
Expand Down
Loading

0 comments on commit 3adf3ba

Please sign in to comment.