10000 Merge pull request #56 from Pliner/master · syk-coder/rabbitmq-tutorials@f39351d · GitHub
[go: up one dir, main page]

Skip to content

Commit f39351d

Browse files
Merge pull request rabbitmq#56 from Pliner/master
Named parameter version of the API rabbitmq#20
2 parents 7fb7fab + 55b57b4 commit f39351d

File tree

12 files changed

+30
-30
lines changed

12 files changed

+30
-30
lines changed

dotnet-visual-studio/1_Receive/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ public static void Main()
1111
using( var connection = factory.CreateConnection() )
1212
using( var channel = connection.CreateModel() )
1313
{
14-
channel.QueueDeclare( "hello", false, false, false, null );
14+
channel.QueueDeclare( queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null);
1515

1616
var consumer = new QueueingBasicConsumer( channel );
17-
channel.BasicConsume( "hello", true, consumer );
17+
channel.BasicConsume( queue: "hello", noAck: true, consumer: consumer );
1818

1919
Console.WriteLine( " [*] Waiting for messages. To exit press CTRL+C" );
2020
while( true )

dotnet-visual-studio/1_Send/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ public static void Main()
1010
using( var connection = factory.CreateConnection() )
1111
using( var channel = connection.CreateModel() )
1212
{
13-
channel.QueueDeclare( "hello", false, false, false, null );
13+
channel.QueueDeclare( queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null );
1414

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

18-
channel.BasicPublish( "", "hello", null, body );
18+
channel.BasicPublish( exchange: "", routingKey: "hello", basicProperties: null, body: body );
1919
Console.WriteLine( " [x] Sent {0}", message );
2020
}
2121

dotnet-visual-studio/2_NewTask/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ public static void Main( string[] args )
1010
using( var connection = factory.CreateConnection() )
1111
using( var channel = connection.CreateModel() )
1212
{
13-
channel.QueueDeclare( "task_queue", true, false, false, null );
13+
channel.QueueDeclare( queue: "task_queue", durable: true, exclusive: false, autoDelete: false, arguments: null );
1414

1515
var message = GetMessage( args );
1616
var body = Encoding.UTF8.GetBytes( message );
1717

1818
var properties = channel.CreateBasicProperties();
1919
properties.SetPersistent( true );
2020

21-
channel.BasicPublish( "", "task_queue", properties, body );
21+
channel.BasicPublish(exchange: "", routingKey: "task_queue", basicProperties: properties, body: body );
2222
Console.WriteLine( " [x] Sent {0}", message );
2323
}
2424

dotnet-visual-studio/2_Worker/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ public static void Main()
1212
using( var connection = factory.CreateConnection() )
1313
using( var channel = connection.CreateModel() )
1414
{
15-
channel.QueueDeclare( "task_queue", true, false, false, null );
15+
channel.QueueDeclare( queue: "task_queue", durable: true, exclusive: false, autoDelete: false, arguments: null );
1616

17-
channel.BasicQos( 0, 1, false );
17+
channel.BasicQos( prefetchSize: 0, prefetchCount: 1, global: false );
1818
var consumer = new QueueingBasicConsumer( channel );
19-
channel.BasicConsume( "task_queue", false, consumer );
19+
channel.BasicConsume( queue: "task_queue", noAck: false, consumer: consumer );
2020

2121
Console.WriteLine( " [*] Waiting for messages. To exit press CTRL+C" );
2222
while( true )
@@ -32,7 +32,7 @@ public static void Main()
3232

3333
Console.WriteLine( " [x] Done" );
3434

35-
channel.BasicAck( ea.DeliveryTag, false );
35+
channel.BasicAck( deliveryTag: ea.DeliveryTag, multiple: false );
3636
}
3737
}
3838
}

dotnet-visual-studio/3_EmitLog/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ public static void Main( string[] args )
1010
using( var connection = factory.CreateConnection() )
1111
using( var channel = connection.CreateModel() )
1212
{
13-
channel.ExchangeDeclare( "logs", "fanout" );
13+
channel.ExchangeDeclare( exchange: "logs", type: "fanout" );
1414

1515
var message = GetMessage( args );
1616
var body = Encoding.UTF8.GetBytes( message );
17-
channel.BasicPublish( "logs", "", null, body );
17+
channel.BasicPublish( exchange: "logs", routingKey: "", basicProperties: null, body: body );
1818
Console.WriteLine( " [x] Sent {0}", message );
1919
}
2020

dotnet-visual-studio/3_ReceiveLogs/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ public static void Main()
1111
using( var connection = factory.CreateConnection() )
1212
using( var channel = connection.CreateModel() )
1313
{
14-
channel.ExchangeDeclare( "logs", "fanout" );
14+
channel.ExchangeDeclare( exchange: "logs", type: "fanout" );
1515

1616
var queueName = channel.QueueDeclare().QueueName;
1717

18-
channel.QueueBind( queueName, "logs", "" );
18+
channel.QueueBind( queue: queueName, exchange: "logs", routingKey: "" );
1919
var consumer = new QueueingBasicConsumer( channel );
20-
channel.BasicConsume( queueName, true, consumer );
20+
channel.BasicConsume( queue: queueName, noAck: true, consumer: consumer );
2121

2222
Console.WriteLine( " [*] Waiting for logs. To exit press CTRL+C" );
2323
while( true )

dotnet-visual-studio/4_EmitLogDirect/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ public static void Main( string[] args )
1111
using( var connection = factory.CreateConnection() )
1212
using( var channel = connection.CreateModel() )
1313
{
14-
channel.ExchangeDeclare( "direct_logs", "direct" );
14+
channel.ExchangeDeclare( exchange: "direct_logs", type: "direct" );
1515

1616
var severity = ( args.Length > 0 ) ? args[0] : "info";
1717
var message = ( args.Length > 1 ) ? string.Join( " ", args.Skip( 1 ).ToArray() ) : "Hello World!";
1818
var body = Encoding.UTF8.GetBytes( message );
19-
channel.BasicPublish( "direct_logs", severity, null, body );
19+
channel.BasicPublish( exchange: "direct_logs", routingKey: severity, basicProperties: null, body: body );
2020
Console.WriteLine( " [x] Sent '{0}':'{1}'", severity, message );
2121
}
2222

dotnet-visual-studio/4_ReceiveLogsDirect/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static void Main( string[] args )
1111
using( var connection = factory.CreateConnection() )
1212
using( var channel = connection.CreateModel() )
1313
{
14-
channel.ExchangeDeclare( "direct_logs", "direct" );
14+
channel.ExchangeDeclare( exchange: "direct_logs", type: "direct" );
1515
var queueName = channel.QueueDeclare().QueueName;
1616

1717
if( args.Length < 1 )
@@ -25,13 +25,13 @@ public static void Main( string[] args )
2525

2626
foreach( var severity in args )
2727
{
28-
channel.QueueBind( queueName, "direct_logs", severity );
28+
channel.QueueBind( queue: queueName, exchange: "direct_logs", routingKey: severity );
2929
}
3030

3131
Console.WriteLine( " [*] Waiting for messages. To exit press CTRL+C" );
3232

3333
var consumer = new QueueingBasicConsumer( channel );
34-
channel.BasicConsume( queueName, true, consumer );
34+
channel.BasicConsume( queue: queueName, noAck: true, consumer: consumer );
3535

3636
while( true )
3737
{

dotnet-visual-studio/5_EmitLogTopic/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static void Main( string[] args )
1111
using( var connection = factory.CreateConnection() )
1212
using( var channel = connection.CreateModel() )
1313
{
14-
channel.ExchangeDeclare( "topic_logs", "topic" );
14+
channel.ExchangeDeclare( exchange: "topic_logs", type: "topic" );
1515

1616
var routingKey = ( args.Length > 0 ) ? args[0] : "anonymous.info";
1717
var message = ( args.Length > 1 ) ? string.Join( " ", args.Skip( 1 ).ToArray() ) : "Hello World!";

dotnet-visual-studio/5_ReceiveLogsTopic/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static void Main( string[] args )
1111
using( var connection = factory.CreateConnection() )
1212
using( var channel = connection.CreateModel() )
1313
{
14-
channel.ExchangeDeclare( "topic_logs", "topic" );
14+
channel.ExchangeDeclare( exchange: "topic_logs", type: "topic" );
1515
var queueName = channel.QueueDeclare().QueueName;
1616

1717
if( args.Length < 1 )
@@ -25,13 +25,13 @@ public static void Main( string[] args )
2525

2626
foreach( var bindingKey in args )
2727
{
28-
channel.QueueBind( queueName, "topic_logs", bindingKey );
28+
channel.QueueBind( queue: queueName, exchange: "topic_logs", routingKey: bindingKey );
2929
}
3030

3131
Console.WriteLine( " [*] Waiting for messages. To exit press CTRL+C" );
3232

3333
var consumer = new QueueingBasicConsumer( channel );
34-
channel.BasicConsume( queueName, true, consumer );
34+
channel.BasicConsume( queue: queueName, noAck: true, consumer: consumer );
3535

3636
while( true )
3737
{

dotnet-visual-studio/6_RPCClient/RPCClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public RPCClient()
2020
channel = connection.CreateModel();
2121
replyQueueName = channel.QueueDeclare().QueueName;
2222
consumer = new QueueingBasicConsumer( channel );
23-
channel.BasicConsume( replyQueueName, true, consumer );
23+
channel.BasicConsume( queue: replyQueueName, noAck: true, consumer: consumer );
2424
}
2525

2626
public string Call( string message )
@@ -31,7 +31,7 @@ public string Call( string message )
3131
props.CorrelationId = corrId;
3232

3333
var messageBytes = Encoding.UTF8.GetBytes( message );
34-
channel.BasicPublish( "", "rpc_queue", props, messageBytes );
34+
channel.BasicPublish( exchange: "", routingKey: "rpc_queue", basicProperties: props, body: messageBytes );
3535

3636
while( true )
3737
{

dotnet-visual-studio/6_RPCServer/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ public static void Main()
1111
using( var connection = factory.CreateConnection() )
1212
using( var channel = connection.CreateModel() )
1313
{
14-
channel.QueueDeclare( "rpc_queue", false, false, false, null );
14+
channel.QueueDeclare( queue: "rpc_queue", durable: false, exclusive: false, autoDelete: false, arguments: null );
1515
channel.BasicQos( 0, 1, false );
1616
var consumer = new QueueingBasicConsumer( channel );
17-
channel.BasicConsume( "rpc_queue", false, consumer );
17+
channel.BasicConsume( queue: "rpc_queue", noAck: false, consumer: consumer );
1818
Console.WriteLine( " [x] Awaiting RPC requests" );
1919

2020
while( true )
@@ -42,8 +42,8 @@ public static void Main()
4242
finally
4343
{
4444
var responseBytes = Encoding.UTF8.GetBytes( response );
45-
channel.BasicPublish( "", props.ReplyTo, replyProps, responseBytes );
46-
channel.BasicAck( ea.DeliveryTag, false );
45+
channel.BasicPublish( exchange: "", routingKey: props.ReplyTo, basicProperties: replyProps, body: responseBytes );
46+
channel.BasicAck( deliveryTag: ea.DeliveryTag, multiple: false );
4747
}
4848
}
4949
}

0 commit comments

Comments
 (0)
0