Skip to content

Commit

Permalink
fix silly SQS test
Browse files Browse the repository at this point in the history
  • Loading branch information
mookid8000 committed Aug 29, 2016
1 parent cc39232 commit 79db89f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Rebus.AmazonSQS.Tests/DeferMessageTest.cs
Expand Up @@ -57,13 +57,13 @@ public async Task CanDeferMessage()
});

var bus = _configurer.Start();
var sendTime = DateTime.UtcNow;

await bus.Defer(TimeSpan.FromSeconds(10), "hej med dig!");

gotTheMessage.WaitOrDie(TimeSpan.FromSeconds(20));

var now = DateTime.UtcNow;
var elapsed = now - receiveTime;
var elapsed = receiveTime - sendTime;

Assert.That(elapsed, Is.GreaterThan(TimeSpan.FromSeconds(8)));
}
Expand Down
14 changes: 10 additions & 4 deletions Rebus.AmazonSQS/AmazonSQSTransport.cs
Expand Up @@ -234,11 +234,17 @@ async Task SendOutgoingMessages(ConcurrentQueue<OutgoingMessage> outgoingMessage
var messageAttributes = CreateAttributesFromHeaders(headers);
var delaySeconds = GetDelaySeconds(headers);
return new SendMessageBatchRequestEntry(messageId, body)
var entry = new SendMessageBatchRequestEntry(messageId, body)
{
MessageAttributes = messageAttributes,
DelaySeconds = delaySeconds,
};
if (delaySeconds != null)
{
entry.DelaySeconds = delaySeconds.Value;
}
return entry;
})
.ToList();
Expand All @@ -256,10 +262,10 @@ async Task SendOutgoingMessages(ConcurrentQueue<OutgoingMessage> outgoingMessage
);
}

static int GetDelaySeconds(IReadOnlyDictionary<string, string> headers)
static int? GetDelaySeconds(IReadOnlyDictionary<string, string> headers)
{
string deferUntilTime;
if (!headers.TryGetValue(Headers.DeferredUntil, out deferUntilTime)) return 0;
if (!headers.TryGetValue(Headers.DeferredUntil, out deferUntilTime)) return null;

var deferUntilDateTimeOffset = deferUntilTime.ToDateTimeOffset();

Expand Down

0 comments on commit 79db89f

Please sign in to comment.