From d32e4bd59c23552e19f96e67e8c5037fd2a631ec Mon Sep 17 00:00:00 2001 From: Yury Pliner Date: Thu, 25 Jun 2015 00:14:27 +0500 Subject: [PATCH 1/2] Named parameter version of the API #20 --- dotnet/EmitLog.cs | 23 +++++----- dotnet/EmitLogDirect.cs | 25 ++++++----- dotnet/EmitLogTopic.cs | 22 ++++------ dotnet/NewTask.cs | 29 ++++++------- dotnet/RPCClient.cs | 21 ++++++---- dotnet/RPCServer.cs | 83 +++++++++++++++++++------------------ dotnet/Receive.cs | 27 ++++++------ dotnet/ReceiveLogs.cs | 31 +++++++------- dotnet/ReceiveLogsDirect.cs | 57 ++++++++++++------------- dotnet/ReceiveLogsTopic.cs | 57 ++++++++++++------------- dotnet/Send.cs | 19 +++++---- dotnet/Worker.cs | 38 ++++++++--------- 12 files changed, 211 insertions(+), 221 deletions(-) diff --git a/dotnet/EmitLog.cs b/dotnet/EmitLog.cs index 37404165..aa48ea75 100644 --- a/dotnet/EmitLog.cs +++ b/dotnet/EmitLog.cs @@ -4,23 +4,26 @@ class EmitLog { - public static void Main(string[] args) + public static void Main( string[] args ) { var factory = new ConnectionFactory() { HostName = "localhost" }; - using (var connection = factory.CreateConnection()) - using (var channel = connection.CreateModel()) + using( var connection = factory.CreateConnection() ) + using( var channel = connection.CreateModel() ) { - channel.ExchangeDeclare("logs", "fanout"); + channel.ExchangeDeclare( exchange: "logs", type: "fanout" ); - var message = GetMessage(args); - var body = Encoding.UTF8.GetBytes(message); - channel.BasicPublish("logs", "", null, body); - Console.WriteLine(" [x] Sent {0}", message); + var message = GetMessage( args ); + var body = Encoding.UTF8.GetBytes( message ); + channel.BasicPublish( exchange: "logs", routingKey: "", basicProperties: null, body: body ); + Console.WriteLine( " [x] Sent {0}", message ); } + + Console.WriteLine( " Press [enter] to exit." ); + Console.ReadLine(); } - private static string GetMessage(string[] args) + private static string GetMessage( string[] args ) { - return ((args.Length > 0) ? string.Join(" ", args) : "info: Hello World!"); + return ( ( args.Length > 0 ) ? string.Join( " ", args ) : "info: Hello World!" ); } } diff --git a/dotnet/EmitLogDirect.cs b/dotnet/EmitLogDirect.cs index 0658050f..7ba375d0 100644 --- a/dotnet/EmitLogDirect.cs +++ b/dotnet/EmitLogDirect.cs @@ -5,23 +5,22 @@ class EmitLogDirect { - public static void Main(string[] args) + public static void Main( string[] args ) { var factory = new ConnectionFactory() { HostName = "localhost" }; - using (var connection = factory.CreateConnection()) + using( var connection = factory.CreateConnection() ) + using( var channel = connection.CreateModel() ) { - using (var channel = connection.CreateModel()) - { - channel.ExchangeDeclare("direct_logs", "direct"); + channel.ExchangeDeclare( exchange: "direct_logs", type: "direct" ); - var severity = (args.Length > 0) ? args[0] : "info"; - var message = (args.Length > 1) ? string.Join(" ", args.Skip(1) - .ToArray()) - : "Hello World!"; - var body = Encoding.UTF8.GetBytes(message); - channel.BasicPublish("direct_logs", severity, null, body); - Console.WriteLine(" [x] Sent '{0}':'{1}'", severity, message); - } + var severity = ( args.Length > 0 ) ? args[0] : "info"; + var message = ( args.Length > 1 ) ? string.Join( " ", args.Skip( 1 ).ToArray() ) : "Hello World!"; + var body = Encoding.UTF8.GetBytes( message ); + channel.BasicPublish( exchange: "direct_logs", routingKey: severity, basicProperties: null, body: body ); + Console.WriteLine( " [x] Sent '{0}':'{1}'", severity, message ); } + + Console.WriteLine( " Press [enter] to exit." ); + Console.ReadLine(); } } diff --git a/dotnet/EmitLogTopic.cs b/dotnet/EmitLogTopic.cs index cef86344..739793fc 100644 --- a/dotnet/EmitLogTopic.cs +++ b/dotnet/EmitLogTopic.cs @@ -5,23 +5,19 @@ class EmitLogTopic { - public static void Main(string[] args) + public static void Main( string[] args ) { var factory = new ConnectionFactory() { HostName = "localhost" }; - using (var connection = factory.CreateConnection()) + using( var connection = factory.CreateConnection() ) + using( var channel = connection.CreateModel() ) { - using (var channel = connection.CreateModel()) - { - channel.ExchangeDeclare("topic_logs", "topic"); + channel.ExchangeDeclare( exchange: "topic_logs", type: "topic" ); - var routingKey = (args.Length > 0) ? args[0] : "anonymous.info"; - var message = (args.Length > 1) ? string.Join(" ", args.Skip(1) - .ToArray()) - : "Hello World!"; - var body = Encoding.UTF8.GetBytes(message); - channel.BasicPublish("topic_logs", routingKey, null, body); - Console.WriteLine(" [x] Sent '{0}':'{1}'", routingKey, message); - } + var routingKey = ( args.Length > 0 ) ? args[0] : "anonymous.info"; + var message = ( args.Length > 1 ) ? string.Join( " ", args.Skip( 1 ).ToArray() ) : "Hello World!"; + var body = Encoding.UTF8.GetBytes( message ); + channel.BasicPublish( "topic_logs", routingKey, null, body ); + Console.WriteLine( " [x] Sent '{0}':'{1}'", routingKey, message ); } } } diff --git a/dotnet/NewTask.cs b/dotnet/NewTask.cs index 15f37075..f7ecec70 100644 --- a/dotnet/NewTask.cs +++ b/dotnet/NewTask.cs @@ -4,29 +4,30 @@ class NewTask { - public static void Main(string[] args) + public static void Main( string[] args ) { var factory = new ConnectionFactory() { HostName = "localhost" }; - using (var connection = factory.CreateConnection()) + using( var connection = factory.CreateConnection() ) + using( var channel = connection.CreateModel() ) { - using (var channel = connection.CreateModel()) - { - channel.QueueDeclare("task_queue", true, false, false, null); + channel.QueueDeclare( queue: "task_queue", durable: true, exclusive: false, autoDelete: false, arguments: null ); - var message = GetMessage(args); - var body = Encoding.UTF8.GetBytes(message); + var message = GetMessage( args ); + var body = Encoding.UTF8.GetBytes( message ); - var properties = channel.CreateBasicProperties(); - properties.SetPersistent(true); + var properties = channel.CreateBasicProperties(); + properties.SetPersistent( true ); - channel.BasicPublish("", "task_queue", properties, body); - Console.WriteLine(" [x] Sent {0}", message); - } + channel.BasicPublish(exchange: "", routingKey: "task_queue", basicProperties: properties, body: body ); + Console.WriteLine( " [x] Sent {0}", message ); } + + Console.WriteLine( " Press [enter] to exit." ); + Console.ReadLine(); } - private static string GetMessage(string[] args) + private static string GetMessage( string[] args ) { - return ((args.Length > 0) ? string.Join(" ", args) : "Hello World!"); + return ( ( args.Length > 0 ) ? string.Join( " ", args ) : "Hello World!" ); } } diff --git a/dotnet/RPCClient.cs b/dotnet/RPCClient.cs index 0ebd3601..1a800912 100644 --- a/dotnet/RPCClient.cs +++ b/dotnet/RPCClient.cs @@ -1,7 +1,10 @@ using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; using RabbitMQ.Client; using RabbitMQ.Client.Events; -using System.Text; class RPCClient { @@ -16,26 +19,26 @@ public RPCClient() connection = factory.CreateConnection(); channel = connection.CreateModel(); replyQueueName = channel.QueueDeclare().QueueName; - consumer = new QueueingBasicConsumer(channel); - channel.BasicConsume(replyQueueName, true, consumer); + consumer = new QueueingBasicConsumer( channel ); + channel.BasicConsume( queue: replyQueueName, noAck: true, consumer: consumer ); } - public string Call(string message) + public string Call( string message ) { var corrId = Guid.NewGuid().ToString(); var props = channel.CreateBasicProperties(); props.ReplyTo = replyQueueName; props.CorrelationId = corrId; - var messageBytes = Encoding.UTF8.GetBytes(message); - channel.BasicPublish("", "rpc_queue", props, messageBytes); + var messageBytes = Encoding.UTF8.GetBytes( message ); + channel.BasicPublish( exchange: "", routingKey: "rpc_queue", basicProperties: props, body: messageBytes ); - while (true) + while( true ) { var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); - if (ea.BasicProperties.CorrelationId == corrId) + if( ea.BasicProperties.CorrelationId == corrId ) { - return Encoding.UTF8.GetString(ea.Body); + return Encoding.UTF8.GetString( ea.Body ); } } } diff --git a/dotnet/RPCServer.cs b/dotnet/RPCServer.cs index be184e55..fccc62f6 100644 --- a/dotnet/RPCServer.cs +++ b/dotnet/RPCServer.cs @@ -8,55 +8,58 @@ class RPCServer public static void Main() { var factory = new ConnectionFactory() { HostName = "localhost" }; - using (var connection = factory.CreateConnection()) + using( var connection = factory.CreateConnection() ) + using( var channel = connection.CreateModel() ) { - using (var channel = connection.CreateModel()) - { - channel.QueueDeclare("rpc_queue", false, false, false, null); - channel.BasicQos(0, 1, false); - var consumer = new QueueingBasicConsumer(channel); - channel.BasicConsume("rpc_queue", false, consumer); - Console.WriteLine(" [x] Awaiting RPC requests"); + channel.QueueDeclare( queue: "rpc_queue", durable: false, exclusive: false, autoDelete: false, arguments: null ); + channel.BasicQos( 0, 1, false ); + var consumer = new QueueingBasicConsumer( channel ); + channel.BasicConsume( queue: "rpc_queue", noAck: false, consumer: consumer ); + Console.WriteLine( " [x] Awaiting RPC requests" ); - while (true) - { - string response = null; - var ea = - (BasicDeliverEventArgs)consumer.Queue.Dequeue(); + while( true ) + { + string response = null; + var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); - var body = ea.Body; - var props = ea.BasicProperties; - var replyProps = channel.CreateBasicProperties(); - replyProps.CorrelationId = props.CorrelationId; + var body = ea.Body; + var props = ea.BasicProperties; + var replyProps = channel.CreateBasicProperties(); + replyProps.CorrelationId = props.CorrelationId; - try - { - var message = Encoding.UTF8.GetString(body); - int n = int.Parse(message); - Console.WriteLine(" [.] fib({0})", message); - response = fib(n).ToString(); - } - catch (Exception e) - { - Console.WriteLine(" [.] " + e.Message); - response = ""; - } - finally - { - var responseBytes = - Encoding.UTF8.GetBytes(response); - channel.BasicPublish("", props.ReplyTo, replyProps, - responseBytes); - channel.BasicAck(ea.DeliveryTag, false); - } + try + { + var message = Encoding.UTF8.GetString( body ); + int n = int.Parse( message ); + Console.WriteLine( " [.] fib({0})", message ); + response = fib( n ).ToString(); + } + catch( Exception e ) + { + Console.WriteLine( " [.] " + e.Message ); + response = ""; + } + finally + { + var responseBytes = Encoding.UTF8.GetBytes( response ); + channel.BasicPublish( exchange: "", routingKey: props.ReplyTo, basicProperties: replyProps, body: responseBytes ); + channel.BasicAck( deliveryTag: ea.DeliveryTag, multiple: false ); } } } } - private static int fib(int n) + /// + /// Assumes only valid positive integer input. + /// Don't expect this one to work for big numbers, and it's probably the slowest recursive implementation possible. + /// + private static int fib( int n ) { - if (n == 0 || n == 1) return n; - return fib(n - 1) + fib(n - 2); + if( n == 0 || n == 1 ) + { + return n; + } + + return fib( n - 1 ) + fib( n - 2 ); } } diff --git a/dotnet/Receive.cs b/dotnet/Receive.cs index 30ed08f7..fe7c9fc2 100644 --- a/dotnet/Receive.cs +++ b/dotnet/Receive.cs @@ -8,25 +8,22 @@ class Receive public static void Main() { var factory = new ConnectionFactory() { HostName = "localhost" }; - using (var connection = factory.CreateConnection()) + using( var connection = factory.CreateConnection() ) + using( var channel = connection.CreateModel() ) { - using (var channel = connection.CreateModel()) - { - channel.QueueDeclare("hello", false, false, false, null); + channel.QueueDeclare( queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null); - var consumer = new QueueingBasicConsumer(channel); - channel.BasicConsume("hello", true, consumer); + var consumer = new QueueingBasicConsumer( channel ); + channel.BasicConsume( queue: "hello", noAck: true, consumer: consumer ); - Console.WriteLine(" [*] Waiting for messages." + - "To exit press CTRL+C"); - while (true) - { - var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); + Console.WriteLine( " [*] Waiting for messages. To exit press CTRL+C" ); + while( true ) + { + var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); - var body = ea.Body; - var message = Encoding.UTF8.GetString(body); - Console.WriteLine(" [x] Received {0}", message); - } + var body = ea.Body; + var message = Encoding.UTF8.GetString( body ); + Console.WriteLine( " [x] Received {0}", message ); } } } diff --git a/dotnet/ReceiveLogs.cs b/dotnet/ReceiveLogs.cs index 76b00a57..34645f4c 100644 --- a/dotnet/ReceiveLogs.cs +++ b/dotnet/ReceiveLogs.cs @@ -8,28 +8,25 @@ class ReceiveLogs public static void Main() { var factory = new ConnectionFactory() { HostName = "localhost" }; - using (var connection = factory.CreateConnection()) + using( var connection = factory.CreateConnection() ) + using( var channel = connection.CreateModel() ) { - using (var channel = connection.CreateModel()) - { - channel.ExchangeDeclare("logs", "fanout"); + channel.ExchangeDeclare( exchange: "logs", type: "fanout" ); - var queueName = channel.QueueDeclare().QueueName; + var queueName = channel.QueueDeclare().QueueName; - channel.QueueBind(queueName, "logs", ""); - var consumer = new QueueingBasicConsumer(channel); - channel.BasicConsume(queueName, true, consumer); + channel.QueueBind( queue: queueName, exchange: "logs", routingKey: "" ); + var consumer = new QueueingBasicConsumer( channel ); + channel.BasicConsume( queue: queueName, noAck: true, consumer: consumer ); - Console.WriteLine(" [*] Waiting for logs." + - "To exit press CTRL+C"); - while (true) - { - var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); + Console.WriteLine( " [*] Waiting for logs. To exit press CTRL+C" ); + while( true ) + { + var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); - var body = ea.Body; - var message = Encoding.UTF8.GetString(body); - Console.WriteLine(" [x] {0}", message); - } + var body = ea.Body; + var message = Encoding.UTF8.GetString( body ); + Console.WriteLine( " [x] {0}", message ); } } } diff --git a/dotnet/ReceiveLogsDirect.cs b/dotnet/ReceiveLogsDirect.cs index 28b731ee..3bf2a1dd 100644 --- a/dotnet/ReceiveLogsDirect.cs +++ b/dotnet/ReceiveLogsDirect.cs @@ -5,45 +5,42 @@ class ReceiveLogsDirect { - public static void Main(string[] args) + public static void Main( string[] args ) { var factory = new ConnectionFactory() { HostName = "localhost" }; - using (var connection = factory.CreateConnection()) + using( var connection = factory.CreateConnection() ) + using( var channel = connection.CreateModel() ) { - using (var channel = connection.CreateModel()) - { - channel.ExchangeDeclare("direct_logs", "direct"); - var queueName = channel.QueueDeclare().QueueName; + channel.ExchangeDeclare( exchange: "direct_logs", type: "direct" ); + var queueName = channel.QueueDeclare().QueueName; - if (args.Length < 1) - { - Console.Error.WriteLine("Usage: {0} [info] [warning] [error]", - Environment.GetCommandLineArgs()[0]); - Environment.ExitCode = 1; - return; - } + if( args.Length < 1 ) + { + Console.Error.WriteLine( "Usage: {0} [info] [warning] [error]", Environment.GetCommandLineArgs()[0] ); + Console.WriteLine( " Press [enter] to exit." ); + Console.ReadLine(); + Environment.ExitCode = 1; + return; + } - foreach (var severity in args) - { - channel.QueueBind(queueName, "direct_logs", severity); - } + foreach( var severity in args ) + { + channel.QueueBind( queue: queueName, exchange: "direct_logs", routingKey: severity ); + } - Console.WriteLine(" [*] Waiting for messages. " + - "To exit press CTRL+C"); + Console.WriteLine( " [*] Waiting for messages. To exit press CTRL+C" ); - var consumer = new QueueingBasicConsumer(channel); - channel.BasicConsume(queueName, true, consumer); + var consumer = new QueueingBasicConsumer( channel ); + channel.BasicConsume( queue: queueName, noAck: true, consumer: consumer ); - while (true) - { - var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); + while( true ) + { + var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); - var body = ea.Body; - var message = Encoding.UTF8.GetString(body); - var routingKey = ea.RoutingKey; - Console.WriteLine(" [x] Received '{0}':'{1}'", - routingKey, message); - } + var body = ea.Body; + var message = Encoding.UTF8.GetString( body ); + var routingKey = ea.RoutingKey; + Console.WriteLine( " [x] Received '{0}':'{1}'", routingKey, message ); } } } diff --git a/dotnet/ReceiveLogsTopic.cs b/dotnet/ReceiveLogsTopic.cs index 66bd4a55..a2b6520f 100644 --- a/dotnet/ReceiveLogsTopic.cs +++ b/dotnet/ReceiveLogsTopic.cs @@ -5,44 +5,41 @@ class ReceiveLogsTopic { - public static void Main(string[] args) + public static void Main( string[] args ) { var factory = new ConnectionFactory() { HostName = "localhost" }; - using (var connection = factory.CreateConnection()) + using( var connection = factory.CreateConnection() ) + using( var channel = connection.CreateModel() ) { - using (var channel = connection.CreateModel()) - { - channel.ExchangeDeclare("topic_logs", "topic"); - var queueName = channel.QueueDeclare().QueueName; + channel.ExchangeDeclare( exchange: "topic_logs", type: "topic" ); + var queueName = channel.QueueDeclare().QueueName; - if (args.Length < 1) - { - Console.Error.WriteLine("Usage: {0} [binding_key...]", - Environment.GetCommandLineArgs()[0]); - Environment.ExitCode = 1; - return; - } + if( args.Length < 1 ) + { + Console.Error.WriteLine( "Usage: {0} [binding_key...]", Environment.GetCommandLineArgs()[0] ); + Console.WriteLine( " Press [enter] to exit." ); + Console.ReadLine(); + Environment.ExitCode = 1; + return; + } - foreach (var bindingKey in args) - { - channel.QueueBind(queueName, "topic_logs", bindingKey); - } + foreach( var bindingKey in args ) + { + channel.QueueBind( queue: queueName, exchange: "topic_logs", routingKey: bindingKey ); + } - Console.WriteLine(" [*] Waiting for messages. " + - "To exit press CTRL+C"); + Console.WriteLine( " [*] Waiting for messages. To exit press CTRL+C" ); - var consumer = new QueueingBasicConsumer(channel); - channel.BasicConsume(queueName, true, consumer); + var consumer = new QueueingBasicConsumer( channel ); + channel.BasicConsume( queue: queueName, noAck: true, consumer: consumer ); - while (true) - { - var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); - var body = ea.Body; - var message = Encoding.UTF8.GetString(body); - var routingKey = ea.RoutingKey; - Console.WriteLine(" [x] Received '{0}':'{1}'", - routingKey, message); - } + while( true ) + { + var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); + var body = ea.Body; + var message = Encoding.UTF8.GetString( body ); + var routingKey = ea.RoutingKey; + Console.WriteLine( " [x] Received '{0}':'{1}'", routingKey, message ); } } } diff --git a/dotnet/Send.cs b/dotnet/Send.cs index 716d4c76..a2419f19 100644 --- a/dotnet/Send.cs +++ b/dotnet/Send.cs @@ -7,18 +7,19 @@ class Send public static void Main() { var factory = new ConnectionFactory() { HostName = "localhost" }; - using (var connection = factory.CreateConnection()) + using( var connection = factory.CreateConnection() ) + using( var channel = connection.CreateModel() ) { - using (var channel = connection.CreateModel()) - { - channel.QueueDeclare("hello", false, false, false, null); + channel.QueueDeclare( queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null ); - string message = "Hello World!"; - var body = Encoding.UTF8.GetBytes(message); + string message = "Hello World!"; + var body = Encoding.UTF8.GetBytes( message ); - channel.BasicPublish("", "hello", null, body); - Console.WriteLine(" [x] Sent {0}", message); - } + channel.BasicPublish( exchange: "", routingKey: "hello", basicProperties: null, body: body ); + Console.WriteLine( " [x] Sent {0}", message ); } + + Console.WriteLine( " Press [enter] to exit." ); + Console.ReadLine(); } } diff --git a/dotnet/Worker.cs b/dotnet/Worker.cs index 1141705e..160d6e53 100644 --- a/dotnet/Worker.cs +++ b/dotnet/Worker.cs @@ -9,34 +9,30 @@ class Worker public static void Main() { var factory = new ConnectionFactory() { HostName = "localhost" }; - using (var connection = factory.CreateConnection()) + using( var connection = factory.CreateConnection() ) + using( var channel = connection.CreateModel() ) { - using (var channel = connection.CreateModel()) - { - channel.QueueDeclare("task_queue", true, false, false, null); + channel.QueueDeclare( queue: "task_queue", durable: true, exclusive: false, autoDelete: false, arguments: null ); - channel.BasicQos(0, 1, false); - var consumer = new QueueingBasicConsumer(channel); - channel.BasicConsume("task_queue", false, consumer); + channel.BasicQos( prefetchSize: 0, prefetchCount: 1, global: false ); + var consumer = new QueueingBasicConsumer( channel ); + channel.BasicConsume( queue: "task_queue", noAck: false, consumer: consumer ); - Console.WriteLine(" [*] Waiting for messages. " + - "To exit press CTRL+C"); - while (true) - { - var ea = - (BasicDeliverEventArgs)consumer.Queue.Dequeue(); + Console.WriteLine( " [*] Waiting for messages. To exit press CTRL+C" ); + while( true ) + { + var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); - var body = ea.Body; - var message = Encoding.UTF8.GetString(body); - Console.WriteLine(" [x] Received {0}", message); + var body = ea.Body; + var message = Encoding.UTF8.GetString( body ); + Console.WriteLine( " [x] Received {0}", message ); - int dots = message.Split('.').Length - 1; - Thread.Sleep(dots * 1000); + int dots = message.Split( '.' ).Length - 1; + Thread.Sleep( dots * 1000 ); - Console.WriteLine(" [x] Done"); + Console.WriteLine( " [x] Done" ); - channel.BasicAck(ea.DeliveryTag, false); - } + channel.BasicAck( deliveryTag: ea.DeliveryTag, multiple: false ); } } } From c8e9c346a9eac8026af29178df94adfc6b138ca9 Mon Sep 17 00:00:00 2001 From: Yury Pliner Date: Thu, 25 Jun 2015 00:41:22 +0500 Subject: [PATCH 2/2] Fixes --- dotnet-visual-studio/1_Receive/Program.cs | 2 +- dotnet-visual-studio/2_NewTask/Program.cs | 2 +- dotnet-visual-studio/5_EmitLogTopic/Program.cs | 2 +- dotnet/EmitLogTopic.cs | 2 +- dotnet/NewTask.cs | 2 +- dotnet/Receive.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dotnet-visual-studio/1_Receive/Program.cs b/dotnet-visual-studio/1_Receive/Program.cs index aade72fb..9d845f51 100644 --- a/dotnet-visual-studio/1_Receive/Program.cs +++ b/dotnet-visual-studio/1_Receive/Program.cs @@ -11,7 +11,7 @@ public static void Main() using( var connection = factory.CreateConnection() ) using( var channel = connection.CreateModel() ) { - channel.QueueDeclare( queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null); + channel.QueueDeclare( queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null ); var consumer = new QueueingBasicConsumer( channel ); channel.BasicConsume( queue: "hello", noAck: true, consumer: consumer ); diff --git a/dotnet-visual-studio/2_NewTask/Program.cs b/dotnet-visual-studio/2_NewTask/Program.cs index b65b10c5..78644fbb 100644 --- a/dotnet-visual-studio/2_NewTask/Program.cs +++ b/dotnet-visual-studio/2_NewTask/Program.cs @@ -18,7 +18,7 @@ public static void Main( string[] args ) var properties = channel.CreateBasicProperties(); properties.SetPersistent( true ); - channel.BasicPublish(exchange: "", routingKey: "task_queue", basicProperties: properties, body: body ); + channel.BasicPublish( exchange: "", routingKey: "task_queue", basicProperties: properties, body: body ); Console.WriteLine( " [x] Sent {0}", message ); } diff --git a/dotnet-visual-studio/5_EmitLogTopic/Program.cs b/dotnet-visual-studio/5_EmitLogTopic/Program.cs index 7b36c528..ff9623e9 100644 --- a/dotnet-visual-studio/5_EmitLogTopic/Program.cs +++ b/dotnet-visual-studio/5_EmitLogTopic/Program.cs @@ -16,7 +16,7 @@ public static void Main( string[] args ) var routingKey = ( args.Length > 0 ) ? args[0] : "anonymous.info"; var message = ( args.Length > 1 ) ? string.Join( " ", args.Skip( 1 ).ToArray() ) : "Hello World!"; var body = Encoding.UTF8.GetBytes( message ); - channel.BasicPublish( "topic_logs", routingKey, null, body ); + channel.BasicPublish( exchange: "topic_logs", routingKey: routingKey, basicProperties: null, body: body ); Console.WriteLine( " [x] Sent '{0}':'{1}'", routingKey, message ); } } diff --git a/dotnet/EmitLogTopic.cs b/dotnet/EmitLogTopic.cs index 739793fc..39941084 100644 --- a/dotnet/EmitLogTopic.cs +++ b/dotnet/EmitLogTopic.cs @@ -16,7 +16,7 @@ public static void Main( string[] args ) var routingKey = ( args.Length > 0 ) ? args[0] : "anonymous.info"; var message = ( args.Length > 1 ) ? string.Join( " ", args.Skip( 1 ).ToArray() ) : "Hello World!"; var body = Encoding.UTF8.GetBytes( message ); - channel.BasicPublish( "topic_logs", routingKey, null, body ); + channel.BasicPublish( exchange: "topic_logs", routingKey: routingKey, basicProperties: null, body: body ); Console.WriteLine( " [x] Sent '{0}':'{1}'", routingKey, message ); } } diff --git a/dotnet/NewTask.cs b/dotnet/NewTask.cs index f7ecec70..f9b56871 100644 --- a/dotnet/NewTask.cs +++ b/dotnet/NewTask.cs @@ -18,7 +18,7 @@ public static void Main( string[] args ) var properties = channel.CreateBasicProperties(); properties.SetPersistent( true ); - channel.BasicPublish(exchange: "", routingKey: "task_queue", basicProperties: properties, body: body ); + channel.BasicPublish( exchange: "", routingKey: "task_queue", basicProperties: properties, body: body ); Console.WriteLine( " [x] Sent {0}", message ); } diff --git a/dotnet/Receive.cs b/dotnet/Receive.cs index fe7c9fc2..fbf5b6a9 100644 --- a/dotnet/Receive.cs +++ b/dotnet/Receive.cs @@ -11,7 +11,7 @@ public static void Main() using( var connection = factory.CreateConnection() ) using( var channel = connection.CreateModel() ) { - channel.QueueDeclare( queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null); + channel.QueueDeclare( queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null ); var consumer = new QueueingBasicConsumer( channel ); channel.BasicConsume( queue: "hello", noAck: true, consumer: consumer );