Skip to content

Commit

Permalink
Merge pull request rabbitmq#70 from rabbitmq/rabbitmq-tutorials-69
Browse files Browse the repository at this point in the history
remove useless whitespaces in argument list
  • Loading branch information
michaelklishin committed Aug 17, 2015
2 parents 31bfdd3 + 71e79d4 commit 8c07f54
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 127 deletions.
14 changes: 7 additions & 7 deletions dotnet-visual-studio/1_Send/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ class Program
public static void Main()
{
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.QueueDeclare( queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null );
channel.QueueDeclare(queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null);

string message = "Hello World!";
var body = Encoding.UTF8.GetBytes( message );
var body = Encoding.UTF8.GetBytes(message);

channel.BasicPublish( exchange: "", routingKey: "hello", basicProperties: null, body: 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.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
}
}
24 changes: 12 additions & 12 deletions dotnet-visual-studio/2_NewTask/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@

class Program
{
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.QueueDeclare( queue: "task_queue", durable: true, exclusive: false, autoDelete: false, arguments: 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 );
properties.SetPersistent(true);

channel.BasicPublish( exchange: "", routingKey: "task_queue", basicProperties: properties, body: 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.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!");
}
}
22 changes: 11 additions & 11 deletions dotnet-visual-studio/3_EmitLog/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@

class Program
{
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( exchange: "logs", type: "fanout" );
channel.ExchangeDeclare(exchange: "logs", type: "fanout");

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 );
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.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!");
}
}
20 changes: 10 additions & 10 deletions dotnet-visual-studio/4_EmitLogDirect/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@

class Program
{
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( exchange: "direct_logs", type: "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( exchange: "direct_logs", routingKey: severity, basicProperties: null, body: 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.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
}
}
18 changes: 9 additions & 9 deletions dotnet-visual-studio/5_EmitLogTopic/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

class Program
{
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( exchange: "topic_logs", type: "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( exchange: "topic_logs", routingKey: routingKey, basicProperties: null, body: 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(exchange: "topic_logs", routingKey: routingKey, basicProperties: null, body: body);
Console.WriteLine(" [x] Sent '{0}':'{1}'", routingKey, message);
}
}
}
16 changes: 8 additions & 8 deletions dotnet-visual-studio/6_RPCClient/RPCClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ public RPCClient()
connection = factory.CreateConnection();
channel = connection.CreateModel();
replyQueueName = channel.QueueDeclare().QueueName;
consumer = new QueueingBasicConsumer( channel );
channel.BasicConsume( queue: replyQueueName, noAck: true, consumer: 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( exchange: "", routingKey: "rpc_queue", basicProperties: props, body: 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);
}
}
}
Expand Down
40 changes: 20 additions & 20 deletions dotnet-visual-studio/6_RPCServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ class Program
public static void Main()
{
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.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" );
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 )
while(true)
{
string response = null;
var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue();
Expand All @@ -29,21 +29,21 @@ public static void Main()

try
{
var message = Encoding.UTF8.GetString( body );
int n = int.Parse( message );
Console.WriteLine( " [.] fib({0})", message );
response = fib( n ).ToString();
var message = Encoding.UTF8.GetString(body);
int n = int.Parse(message);
Console.WriteLine(" [.] fib({0})", message);
response = fib(n).ToString();
}
catch( Exception e )
catch(Exception e)
{
Console.WriteLine( " [.] " + e.Message );
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 );
var responseBytes = Encoding.UTF8.GetBytes(response);
channel.BasicPublish(exchange: "", routingKey: props.ReplyTo, basicProperties: replyProps, body: responseBytes);
channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);
}
}
}
Expand All @@ -53,13 +53,13 @@ public static void Main()
/// 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.
/// </summary>
private static int fib( int n )
private static int fib(int n)
{
if( n == 0 || n == 1 )
if(n == 0 || n == 1)
{
return n;
}

return fib( n - 1 ) + fib( n - 2 );
return fib(n - 1) + fib(n - 2);
}
}
22 changes: 11 additions & 11 deletions dotnet/EmitLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +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( exchange: "logs", type: "fanout" );
channel.ExchangeDeclare(exchange: "logs", type: "fanout");

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 );
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.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!");
}
}
20 changes: 10 additions & 10 deletions dotnet/EmitLogDirect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +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 channel = connection.CreateModel() )
using(var connection = factory.CreateConnection())
using(var channel = connection.CreateModel())
{
channel.ExchangeDeclare( exchange: "direct_logs", type: "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( exchange: "direct_logs", routingKey: severity, basicProperties: null, body: 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.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
}
}
18 changes: 9 additions & 9 deletions dotnet/EmitLogTopic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +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 channel = connection.CreateModel() )
using(var connection = factory.CreateConnection())
using(var channel = connection.CreateModel())
{
channel.ExchangeDeclare( exchange: "topic_logs", type: "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( exchange: "topic_logs", routingKey: routingKey, basicProperties: null, body: 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(exchange: "topic_logs", routingKey: routingKey, basicProperties: null, body: body);
Console.WriteLine(" [x] Sent '{0}':'{1}'", routingKey, message);
}
}
}
Loading

0 comments on commit 8c07f54

Please sign in to comment.