Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
1 EasyNetQ.Hosepipe/EasyNetQ.Hosepipe.csproj
@@ -49,6 +49,7 @@
<Link>Properties\Version.cs</Link>
</Compile>
<Compile Include="ArgParser.cs" />
+ <Compile Include="EasyNetQHosepipeException.cs" />
<Compile Include="ErrorRetry.cs" />
<Compile Include="HosepipeConnection.cs" />
<Compile Include="FileMessageWriter.cs" />
View
24 EasyNetQ.Hosepipe/EasyNetQHosepipeException.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Runtime.Serialization;
+
+namespace EasyNetQ.Hosepipe
+{
+ [Serializable]
+ public class EasyNetQHosepipeException : Exception
+ {
+ //
+ // For guidelines regarding the creation of new exception types, see
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
+ // and
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
+ //
+
+ public EasyNetQHosepipeException() {}
+ public EasyNetQHosepipeException(string message) : base(message) {}
+ public EasyNetQHosepipeException(string message, Exception inner) : base(message, inner) {}
+
+ protected EasyNetQHosepipeException(
+ SerializationInfo info,
+ StreamingContext context) : base(info, context) {}
+ }
+}
View
10 EasyNetQ.Hosepipe/FileMessageWriter.cs
@@ -17,7 +17,15 @@ public void Write(IEnumerable<string> messages, QueueParameters parameters)
{
Console.WriteLine("Overwriting existing messsage file: {0}", path);
}
- File.WriteAllText(path, message);
+ try
+ {
+ File.WriteAllText(path, message);
+ }
+ catch (DirectoryNotFoundException)
+ {
+ throw new EasyNetQHosepipeException(
+ string.Format("Directory '{0}' does not exist", parameters.MessageFilePath));
+ }
count++;
}
}
View
17 EasyNetQ.Hosepipe/HosepipeConnection.cs
@@ -1,4 +1,6 @@
-using RabbitMQ.Client;
+using System;
+using RabbitMQ.Client;
+using RabbitMQ.Client.Exceptions;
namespace EasyNetQ.Hosepipe
{
@@ -13,7 +15,18 @@ public static IConnection FromParamters(QueueParameters parameters)
UserName = parameters.Username,
Password = parameters.Password
};
- return connectionFactory.CreateConnection();
+ try
+ {
+ return connectionFactory.CreateConnection();
+ }
+ catch (BrokerUnreachableException)
+ {
+ throw new EasyNetQHosepipeException(string.Format(
+ "The broker at '{0}', VirtualHost '{1}', is unreachable. This message can also be caused " +
+ "by incorrect credentials.",
+ parameters.HostName,
+ parameters.VHost));
+ }
}
}
}
View
36 EasyNetQ.Hosepipe/Program.cs
@@ -63,26 +63,34 @@ public void Start(string[] args)
arguments.WithKey("p", a => parameters.Password = a.Value);
arguments.WithKey("o", a => parameters.MessageFilePath = a.Value);
- arguments.At(0, "dump", () => arguments.WithKey("q", a =>
+ try
{
- parameters.QueueName = a.Value;
- Dump(parameters);
- }).FailWith(messsage("No Queue Name given")));
+ arguments.At(0, "dump", () => arguments.WithKey("q", a =>
+ {
+ parameters.QueueName = a.Value;
+ Dump(parameters);
+ }).FailWith(messsage("No Queue Name given")));
- arguments.At(0, "insert", () => arguments.WithKey("q", a =>
- {
- parameters.QueueName = a.Value;
- Insert(parameters);
- }).FailWith(messsage("No Queue Name given")));
+ arguments.At(0, "insert", () => arguments.WithKey("q", a =>
+ {
+ parameters.QueueName = a.Value;
+ Insert(parameters);
+ }).FailWith(messsage("No Queue Name given")));
- arguments.At(0, "err", () => ErrorDump(parameters));
+ arguments.At(0, "err", () => ErrorDump(parameters));
- arguments.At(0, "retry", () => Retry(parameters));
+ arguments.At(0, "retry", () => Retry(parameters));
- arguments.At(0, "?", PrintUsage);
+ arguments.At(0, "?", PrintUsage);
- // print usage if there are no arguments
- arguments.At(0, a => {}).FailWith(PrintUsage);
+ // print usage if there are no arguments
+ arguments.At(0, a => {}).FailWith(PrintUsage);
+ }
+ catch (EasyNetQHosepipeException easyNetQHosepipeException)
+ {
+ Console.WriteLine("Operation Failed:");
+ Console.WriteLine(easyNetQHosepipeException.Message);
+ }
if(!succeeded)
{
View
1 Mike.AmqpSpike/Mike.AmqpSpike.csproj
@@ -57,6 +57,7 @@
<Compile Include="IO.Ntfs\StreamName.cs" />
<Compile Include="JsonNetSpike.cs" />
<Compile Include="LambdaSpike.cs" />
+ <Compile Include="PerformanceCounterSpike.cs" />
<Compile Include="PingPongSpike.cs" />
<Compile Include="PointToPoint.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
View
41 Mike.AmqpSpike/PerformanceCounterSpike.cs
@@ -0,0 +1,41 @@
+using System.Diagnostics;
+
+namespace Mike.AmqpSpike
+{
+ public class PerformanceCounterSpike
+ {
+ public void CreatePerformanceCategory()
+ {
+ const string category = "MikePerfSpike";
+
+ if (!PerformanceCounterCategory.Exists(category))
+ {
+ var counters = new CounterCreationDataCollection();
+
+ // 1. counter for counting values
+ var totalOps = new CounterCreationData
+ {
+ CounterName = "# of operations executed",
+ CounterHelp = "Total number of operations that have been executed",
+ CounterType = PerformanceCounterType.NumberOfItems32
+ };
+ counters.Add(totalOps);
+
+ // 2. counter for counting operations per second
+ var opsPerSecond = new CounterCreationData
+ {
+ CounterName = "# of operations/second",
+ CounterHelp = "Number of operations per second",
+ CounterType = PerformanceCounterType.RateOfCountsPerSecond32
+ };
+ counters.Add(opsPerSecond);
+
+ PerformanceCounterCategory.Create(
+ category,
+ "An experiment",
+ PerformanceCounterCategoryType.MultiInstance,
+ counters);
+ }
+ }
+ }
+}

No commit comments for this range

Something went wrong with that request. Please try again.