1
0
mirror of synced 2024-07-01 08:17:39 +00:00

Renamed StaticQueue attribute to DurableQueue to match RabbitMQ terminology (breaking change)

Changed default delivery mode to persistent
This commit is contained in:
Mark van Renswoude 2017-02-12 19:15:56 +01:00
parent 120108bd41
commit eb017e7b63
4 changed files with 11 additions and 8 deletions

View File

@ -12,12 +12,12 @@ namespace Tapeti.Annotations
/// for deploy-time management of durable queues (shameless plug intended). /// for deploy-time management of durable queues (shameless plug intended).
/// </remarks> /// </remarks>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class StaticQueueAttribute : Attribute public class DurableQueueAttribute : Attribute
{ {
public string Name { get; set; } public string Name { get; set; }
public StaticQueueAttribute(string name) public DurableQueueAttribute(string name)
{ {
Name = name; Name = name;
} }

View File

@ -46,7 +46,7 @@
<Compile Include="MessageControllerAttribute.cs" /> <Compile Include="MessageControllerAttribute.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RequestAttribute.cs" /> <Compile Include="RequestAttribute.cs" />
<Compile Include="StaticQueueAttribute.cs" /> <Compile Include="DurableQueueAttribute.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -137,9 +137,12 @@ namespace Tapeti.Connection
return taskQueue.Value.Add(async () => return taskQueue.Value.Add(async () =>
{ {
var messageProperties = properties ?? new BasicProperties(); var messageProperties = properties ?? new BasicProperties();
if (messageProperties.Timestamp.UnixTime == 0) if (!messageProperties.IsTimestampPresent())
messageProperties.Timestamp = new AmqpTimestamp(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds()); messageProperties.Timestamp = new AmqpTimestamp(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds());
if (!messageProperties.IsDeliveryModePresent())
messageProperties.DeliveryMode = 2; // Persistent
var body = messageSerializer.Serialize(message, messageProperties); var body = messageSerializer.Serialize(message, messageProperties);
(await GetChannel()) (await GetChannel())

View File

@ -291,16 +291,16 @@ namespace Tapeti
protected QueueInfo GetQueueInfo(MemberInfo member) protected QueueInfo GetQueueInfo(MemberInfo member)
{ {
var dynamicQueueAttribute = member.GetCustomAttribute<DynamicQueueAttribute>(); var dynamicQueueAttribute = member.GetCustomAttribute<DynamicQueueAttribute>();
var staticQueueAttribute = member.GetCustomAttribute<StaticQueueAttribute>(); var durableQueueAttribute = member.GetCustomAttribute<DurableQueueAttribute>();
if (dynamicQueueAttribute != null && staticQueueAttribute != null) if (dynamicQueueAttribute != null && durableQueueAttribute != null)
throw new TopologyConfigurationException($"Cannot combine static and dynamic queue attributes on {member.Name}"); throw new TopologyConfigurationException($"Cannot combine static and dynamic queue attributes on {member.Name}");
if (dynamicQueueAttribute != null) if (dynamicQueueAttribute != null)
return new QueueInfo { Dynamic = true }; return new QueueInfo { Dynamic = true };
if (staticQueueAttribute != null) if (durableQueueAttribute != null)
return new QueueInfo { Dynamic = false, Name = staticQueueAttribute.Name }; return new QueueInfo { Dynamic = false, Name = durableQueueAttribute.Name };
return null; return null;
} }