Permalink
Browse files

Nicer console output

  • Loading branch information...
1 parent c5269b4 commit 2a92290798b1cee2a3820342449eeb0f9b508a02 @ayende ayende committed Jan 18, 2011
Showing with 49 additions and 18 deletions.
  1. +9 −4 Raven.MQ.Server/Program.cs
  2. +15 −14 Raven.MQ.Tryouts/Program.cs
  3. +25 −0 Raven.MQ/Impl/Queues.cs
@@ -12,6 +12,7 @@
using Raven.Http;
using RavenMQ.Config;
using RavenMQ.Extensions;
+using RavenMQ.Impl;
using RavenMQ.Server.Responders;
namespace Raven.MQ.Server
@@ -149,10 +150,14 @@ private static void RunInDebugMode(Raven.Http.AnonymousUserAccessMode? anonymous
ravenConfiguration.AnonymousUserAccessMode = anonymousUserAccessMode.Value;
using (new RavenMqServer(ravenConfiguration))
{
- Console.WriteLine("Raven MQ is ready to process requests.");
- Console.WriteLine("Data directory: {0}, HostName: {1} Port: {2}", ravenConfiguration.DataDirectory, ravenConfiguration.HostName ?? "<any>", ravenConfiguration.Port);
- Console.WriteLine("Press the enter key to stop the server or enter 'cls' and then enter to clear the log");
- while (true)
+
+ Console.WriteLine("RavenMQ is ready to process requests. Build {0}, Version {1}", Queues.BuildVersion, Queues.ProductVersion);
+ Console.WriteLine("Data directory: {0}", ravenConfiguration.DataDirectory);
+ Console.WriteLine("HostName: {0} Port: {1}, Storage: Munin", ravenConfiguration.HostName ?? "<any>",
+ ravenConfiguration.Port);
+ Console.WriteLine("Server Url: {0}", ravenConfiguration.ServerUrl);
+ Console.WriteLine("Press <enter> to stop or 'cls' and <enter> to clear the log");
+ while (true)
{
var readLine = Console.ReadLine();
if (!"CLS".Equals(readLine, StringComparison.InvariantCultureIgnoreCase))
@@ -1,31 +1,32 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Raven.Abstractions.Data;
using Raven.MQ.Client;
namespace Raven.MQ.Tryouts
{
class Program
{
- static void Main(string[] args)
+ static void Main()
{
- using(var connection = RavenMQConnection.Connect("http://localhost:8181"))
- {
- connection.
- Subscribe<User>("/queues/abc", (context, message) => Console.WriteLine(message.Name));
- connection
- .StartPublishing
- .Add("/queues/abc", new User {Name = "Ayende"})
- .PublishAsync();
+ var con = new RavenMQConnection(new Uri("http://AYENDEPC:8181/"));
+
+ con.Subscribe<User>("/queues/users/1234", (context, msg) => Console.WriteLine(msg.Name));
+
+ con.Subscribe<User>("/streams/users/1234", (context, msg) => Console.WriteLine(msg.Name));
- Console.ReadLine();
+ for (int i = 0; i < 100; i++)
+ {
+ con.StartPublishing
+ .Add("/streams/users/1234", new User {Name = "users/" + i})
+ .Add("/queues/users/1234", new User {Name = "streams/" + i})
+ .PublishAsync();
}
+
+ Console.ReadLine();
}
}
+
public class User
{
public string Name { get; set; }
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
+using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
@@ -246,5 +247,29 @@ public IEnumerable<string> GetQueueNames(int start, int pageSize)
);
return names;
}
+
+
+ static string buildVersion;
+ public static string BuildVersion
+ {
+ get
+ {
+ if (buildVersion == null)
+ buildVersion = FileVersionInfo.GetVersionInfo(typeof(Queues).Assembly.Location).FilePrivatePart.ToString();
+ return buildVersion;
+ }
+ }
+
+ static string productVersion;
+
+ public static string ProductVersion
+ {
+ get
+ {
+ if (productVersion == null)
+ productVersion = FileVersionInfo.GetVersionInfo(typeof(Queues).Assembly.Location).ProductVersion;
+ return productVersion;
+ }
+ }
}
}

0 comments on commit 2a92290

Please sign in to comment.