Skip to content

Commit

Permalink
Merge pull request #553 from Particular/hotfix-1.6.2
Browse files Browse the repository at this point in the history
Hotfix 1.6.2
  • Loading branch information
mikeminutillo committed Sep 16, 2015
2 parents cceb599 + 2683a8a commit a330223
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 499 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class MyContext : ScenarioContext
}

[Test]
[Ignore("Test is flakey on Azure ServiceBus Transport on build server")]
public void Should_be_reflected_as_active_endpoints_in_the_heartbeat_summary()
{
var context = new MyContext();
Expand Down Expand Up @@ -75,7 +76,7 @@ public void Should_be_reflected_as_active_endpoints_in_the_heartbeat_summary()
{
if(otherEndpoint.MonitorHeartbeat)
{
Console.WriteLine("Disabling Heartbeats on {0}", otherEndpoint.MonitorHeartbeat);
Console.WriteLine("Disabling Heartbeats on {0}", otherEndpoint.Name);
Patch("/api/endpoints/" + otherEndpoint.Id, new EndpointUpdateModel
{
MonitorHeartbeat = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ public void Filter_out_system_messages()
Id = "1",
};

processedMessage.MessageMetadata["IsSystemMessage"] = true;
processedMessage.MakeSystemMessage();
session.Store(processedMessage);

var processedMessage2 = new ProcessedMessage
{
Id = "2",
};

processedMessage2.MessageMetadata["IsSystemMessage"] = false;
processedMessage2.MakeSystemMessage(false);
session.Store(processedMessage2);

session.SaveChanges();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Processed_messages_are_being_expired()
Id = "2",
ProcessedAt = DateTime.UtcNow.AddHours(-(Settings.HoursToKeepMessagesBeforeExpiring * 2)),
};
processedMessage2.MessageMetadata["IsSystemMessage"] = true;
processedMessage2.MakeSystemMessage();

using (var session = documentStore.OpenSession())
{
Expand Down Expand Up @@ -117,7 +117,7 @@ public void Only_processed_messages_are_being_expired()
Id = "2",
ProcessedAt = DateTime.UtcNow,
};
processedMessage2.MessageMetadata["IsSystemMessage"] = true;
processedMessage2.MakeSystemMessage();

using (var session = documentStore.OpenSession())
{
Expand Down Expand Up @@ -155,7 +155,7 @@ public void Stored_bodies_are_being_removed_when_message_expires()
ProcessedAt = DateTime.UtcNow.AddHours(-(Settings.HoursToKeepMessagesBeforeExpiring * 2))
};

processedMessage.MessageMetadata["MessageId"] = messageId;
processedMessage.SetMessageId(messageId);

using (var session = documentStore.OpenSession())
{
Expand Down
14 changes: 14 additions & 0 deletions src/ServiceControl.UnitTests/MessageExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using ServiceControl.MessageAuditing;

public static class MessageExtensions
{
public static void MakeSystemMessage(this ProcessedMessage message, bool isSystem = true)
{
message.MessageMetadata["IsSystemMessage"] = isSystem;
}

public static void SetMessageId(this ProcessedMessage message, string messageId)
{
message.MessageMetadata["MessageId"] = messageId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<Compile Include="Infrastructure\PreventReindexing.cs" />
<Compile Include="Infrastructure\RavenDB\Indexes\InMemoryStoreBuilder.cs" />
<Compile Include="Infrastructure\RavenDB\RavenBootstrapperTests.cs" />
<Compile Include="MessageExtensions.cs" />
<Compile Include="RavenIndexAwaiter.cs" />
<Compile Include="Infrastructure\TransportMessageExtensionsTests.cs" />
<Compile Include="Operations\UpdateLicenseEnricherTest.cs" />
Expand Down
4 changes: 4 additions & 0 deletions src/ServiceControl/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Particular.ServiceControl
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.ServiceProcess;
using Autofac;
using Hosting;
Expand All @@ -25,6 +26,9 @@ public class Bootstrapper

public Bootstrapper(ServiceBase host = null, HostArguments hostArguments = null, Configure configure = null)
{
// .NET default limit is 10. RavenDB in conjunction with transports that use HTTP exceeds that limit.
ServicePointManager.DefaultConnectionLimit = Settings.HttpDefaultConnectionLimit;

Settings.ServiceName = DetermineServiceName(host, hostArguments);
ConfigureLogging();
var containerBuilder = new ContainerBuilder();
Expand Down
2 changes: 2 additions & 0 deletions src/ServiceControl/Infrastructure/Settings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,7 @@ static string DefaultLogPathForInstance()
}
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), string.Format("Particular\\{0}\\logs", ServiceName));
}

public static int HttpDefaultConnectionLimit = SettingsReader<int>.Read("HttpDefaultConnectionLimit", 100);
}
}
9 changes: 1 addition & 8 deletions src/ServiceControl/Operations/AuditQueueImport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using NServiceBus.Pipeline;
using NServiceBus.Satellites;
using NServiceBus.Transports;
using NServiceBus.Transports.Msmq;
using NServiceBus.Unicast.Messages;
using NServiceBus.Unicast.Transport;
using Raven.Client;
Expand All @@ -28,11 +27,6 @@ public class AuditQueueImport : IAdvancedSatellite, IDisposable

#pragma warning restore 618

public AuditQueueImport(IDequeueMessages receiver)
{
disabled = receiver is MsmqDequeueStrategy;
}

public bool Handle(TransportMessage message)
{
InnerHandle(message);
Expand Down Expand Up @@ -107,7 +101,7 @@ public Address InputAddress

public bool Disabled
{
get { return disabled; }
get { return false; }
}

public Action<TransportReceiver> GetReceiverCustomization()
Expand All @@ -132,6 +126,5 @@ public void Dispose()
SatelliteImportFailuresHandler satelliteImportFailuresHandler;

static readonly ILog Logger = LogManager.GetLogger(typeof(AuditQueueImport));
bool disabled;
}
}
16 changes: 9 additions & 7 deletions src/ServiceControl/Operations/BodyStorage/BodyStorageEnricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@ public override void Enrich(ImportMessage message)
bool TryStoreBody(ImportMessage message, int bodySize, string contentType)
{
var bodyId = message.MessageId;
var stored = false;
var storedInBodyStorage = false;
var bodyUrl = string.Format("/messages/{0}/body", bodyId);
var isFailedMessage = message is ImportFailedMessage;
var isBinary = contentType.Contains("binary");
var isBelowMaxSize = bodySize <= Settings.MaxBodySizeToStore;
var avoidsLargeObjectHeap = bodySize < LargeObjectHeapThreshold;

if (isFailedMessage || (isBinary && isBelowMaxSize))
if (isFailedMessage || isBelowMaxSize)
{
bodyUrl = StoreBodyInBodyStorage(message, bodyId, contentType, bodySize);
stored = true;
storedInBodyStorage = true;
}

if (isBelowMaxSize && !isBinary)
if (isBelowMaxSize && avoidsLargeObjectHeap && !isBinary)
{
message.Metadata.Add("Body", Encoding.UTF8.GetString(message.PhysicalMessage.Body));
stored = true;
message.Metadata.Add("Body", Encoding.UTF8.GetString(message.PhysicalMessage.Body));
}

message.Metadata.Add("BodyUrl", bodyUrl);

return stored;
return storedInBodyStorage;
}

static int GetContentLength(ImportMessage message)
Expand Down Expand Up @@ -84,5 +84,7 @@ string StoreBodyInBodyStorage(ImportMessage message, string bodyId, string conte
return bodyUrl;
}
}

static int LargeObjectHeapThreshold = 85*1024;
}
}
Loading

0 comments on commit a330223

Please sign in to comment.