public void multiple_messages_and_then_starting_messages_should_be_forwarded_to_bus() { Consumer.SetWaitingCount(3); Queue.Publish(new TestMessage()); Queue.Publish(new TestMessage2()); Queue.Publish(new TestMessage3()); try { Queue.Start(); Consumer.Wait(); } finally { Queue.Stop(); } Assert.That(Consumer.HandledMessages.ContainsSingle <TestMessage>() && Consumer.HandledMessages.ContainsSingle <TestMessage2>() && Consumer.HandledMessages.ContainsSingle <TestMessage3>()); }
static void Main(string[] args) { var queue = new Queue(); queue.Start(); Console.WriteLine("Hit any to start."); Console.ReadKey(); string key = ""; var qItem1 = new QueueItem { IntValue = 10, StringValue = "Blarh" }; while (key != "a") { queue.Enqueue(qItem1); } queue.Stop(); }
public void all_messages_in_the_queue_should_be_delivered() { #if DEBUG Assert.Ignore( "This test is not supported with DEBUG conditional since all exceptions are thrown in DEBUG builds."); #else Consumer.SetWaitingCount(3); Queue.Publish(new TestMessage()); Queue.Publish(new ExecutableTestMessage(() => { throw new NullReferenceException(); })); Queue.Publish(new TestMessage2()); Queue.Start(); Consumer.Wait(); Assert.IsTrue(Consumer.HandledMessages.ContainsSingle <TestMessage>()); Assert.IsTrue(Consumer.HandledMessages.ContainsSingle <ExecutableTestMessage>()); Assert.IsTrue(Consumer.HandledMessages.ContainsSingle <TestMessage2>()); #endif }
private static void InitQueue(Machine machine) { var role = config["role"]; var sqs = config["amazonSqsBaseUri"]; var uri = $"{sqs}/{role}"; var region = config["amazonSqsRegion"]; var key = config["amazonSqsKey"]; var secret = config["amazonSqsSecret"]; queue = new Queue(uri, region, key, secret, m => { try { machine.Execute(m); } catch (Exception ex) { Console.WriteLine($"Message queue command error: {ex.Message} ({m})"); } }); queue.Start(); Console.WriteLine($"Role: {role} ({uri})"); Console.WriteLine($"Relay: {config["relayQueueName"]} ({config["relayQueueId"]})"); }
public void Start() { if (isStarted) { throw new Exception("Server has already been started!"); } isStarted = true; Log.Debug("Starting Server..."); // Load existing or default server configuration ServerConfiguration.Load(); MessageRegistry.Scan(Assembly.GetExecutingAssembly()); MessageRegistry.Scan(typeof(ILibraryAssembly).Assembly); MessageRegistry.Scan(typeof(IFrameworkAssembly).Assembly); // TODO: Cache Project Package Index? //ProjectPackages.Initialize(); Sessions.Start(); Queue.Start(); var taskVariables = Task.Run(() => Variables.Load(Configuration.VariablesDirectory)); var taskHttp = Task.Run(() => StartHttpServer()); var taskAgents = Task.Run(() => Agents.Load()); var taskProjects = Task.Run(() => Projects.Load()); Task.WaitAll( taskVariables, taskAgents, taskProjects, taskHttp); Log.Info("Server started."); }
public override void SetUp() { base.SetUp(); Queue.Start(); }
public void second_time_should_not_throw() { Queue.Start(); Queue.Stop(); Assert.DoesNotThrow(() => Queue.Stop()); }
public void gracefully_should_not_throw() { Queue.Start(); Assert.DoesNotThrow(() => Queue.Stop()); }
public void after_being_stopped_should_throw() { Queue.Stop(); Assert.Throws <InvalidOperationException>(() => Queue.Start()); }
public void multiple_times_should_throw() { Assert.Throws <InvalidOperationException>(() => Queue.Start()); }
public void gracefully_should_not_throw() { Assert.Throws <InvalidOperationException>(() => Queue.Start()); }