Skip to content

Commit

Permalink
Update examples to match the latest code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ifgris committed Jan 9, 2024
1 parent 3385406 commit b9409fb
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 29 deletions.
6 changes: 3 additions & 3 deletions Example/Example.Autofac/ConsumeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ namespace Example.Autofac;
public class ConsumeService : RabbitSubscriber
{
private readonly ILogger<RabbitSubscriber>? _logger;
public ConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger) : base(consumer, logger)

public ConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName) : base(consumer, logger, consumerName)
{
SetConsumer("FooFirstQueueConsumer");
_logger = logger;
}

protected override bool HandleMessage(string message)
Expand Down
2 changes: 1 addition & 1 deletion Example/Example.Autofac/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
// register BackgroundService
services.AddHostedService<PublishService>();
services.AddHostedService<ConsumeService>();
services.AddRabbitSubscriber<ConsumeService>("FooFirstQueueConsumer");
});
3 changes: 1 addition & 2 deletions Example/Example.ConsumerQuickStart/ConsumeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ namespace Example.ConsumerQuickStart;

public class ConsumeService : RabbitSubscriber
{
public ConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger) : base(consumer, logger)
public ConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName) : base(consumer, logger, consumerName)
{
SetConsumer("FooSecondQueueConsumer");
}

// protected override bool HandleMessage(string message)
Expand Down
2 changes: 1 addition & 1 deletion Example/Example.ConsumerQuickStart/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
}
});

var consumeService = new ConsumeService(consumer, null);
var consumeService = new ConsumeService(consumer, null, "FooSecondQueueConsumer");

consumeService.StartAsync(CancellationToken.None);

Check warning on line 22 in Example/Example.ConsumerQuickStart/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net6.0)

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 22 in Example/Example.ConsumerQuickStart/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net6.0)

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 22 in Example/Example.ConsumerQuickStart/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net7.0)

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 22 in Example/Example.ConsumerQuickStart/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net7.0)

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 22 in Example/Example.ConsumerQuickStart/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net8.0)

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 22 in Example/Example.ConsumerQuickStart/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net8.0)

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
7 changes: 3 additions & 4 deletions Example/Example.MultiConsumers/FirstConsumeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ namespace Example.MultiConsumers;
public class FirstConsumeService : RabbitSubscriber
{
private readonly ILogger<RabbitSubscriber>? _logger;
public FirstConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger) : base(consumer, logger)

public FirstConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName) : base(consumer, logger, consumerName)
{
_logger = logger;
SetConsumer("FooFirstQueueConsumer");
}

protected override bool HandleMessage(string message)
{
_logger?.LogInformation(message);
Expand Down
4 changes: 2 additions & 2 deletions Example/Example.MultiConsumers/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
logger.LogInformation("Program init");

// register BackgroundService
builder.Services.AddHostedService<FirstConsumeService>();
builder.Services.AddHostedService<SecondConsumeService>();
builder.Services.AddRabbitSubscriber<FirstConsumeService>("FooFirstQueueConsumer");
builder.Services.AddRabbitSubscriber<SecondConsumeService>("FooSecondQueueConsumer");

using IHost host = builder.Build();

Expand Down
3 changes: 1 addition & 2 deletions Example/Example.MultiConsumers/SecondConsumeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ public class SecondConsumeService : RabbitSubscriber
{
private readonly IRabbitConsumer _consumer;

public SecondConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger) : base(consumer, logger)
public SecondConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName) : base(consumer, logger, consumerName)
{
_consumer = consumer;
SetConsumer("FooSecondQueueConsumer");
}
}
4 changes: 2 additions & 2 deletions Example/Example.NLog/ConsumeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ namespace Example.NLog;
public class ConsumeService : RabbitSubscriber
{
private readonly ILogger<RabbitSubscriber>? _logger;
public ConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger) : base(consumer, logger)

public ConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName) : base(consumer, logger, consumerName)
{
_logger = logger;
SetConsumer("FooFirstQueueConsumer");
}

protected override bool HandleMessage(string message)
Expand Down
2 changes: 1 addition & 1 deletion Example/Example.NLog/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
// register BackgroundService
services.AddHostedService<PublishService>();
services.AddHostedService<ConsumeService>();
services.AddRabbitSubscriber<ConsumeService>("FooFirstQueueConsumer");
});
3 changes: 1 addition & 2 deletions Example/Example.ProducerInConsumer/ConsumeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ public class ConsumeService : RabbitSubscriber
{
private readonly IRabbitProducer _producer;

public ConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, IRabbitProducer producer) : base(consumer, logger)
public ConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName, IRabbitProducer producer) : base(consumer, logger, consumerName)
{
_producer = producer;
SetConsumer("BarFirstQueueConsumer");
}

protected override bool HandleMessage(string message)
Expand Down
2 changes: 1 addition & 1 deletion Example/Example.ProducerInConsumer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
logger.LogInformation("Program init");

// register BackgroundService
builder.Services.AddHostedService<ConsumeService>();
builder.Services.AddRabbitSubscriber<ConsumeService>("BarFirstQueueConsumer");

using IHost host = builder.Build();

Expand Down
3 changes: 1 addition & 2 deletions Example/Example.ReadSettings/ConsumeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ public class ConsumeService : RabbitSubscriber
{
private readonly ILogger<RabbitSubscriber>? _logger;

public ConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger) : base(consumer, logger)
public ConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string? consumerName = null) : base(consumer, logger, consumerName)

Check warning on line 10 in Example/Example.ReadSettings/ConsumeService.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net6.0)

Possible null reference argument for parameter 'consumerName' in 'RabbitSubscriber.RabbitSubscriber(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName)'.

Check warning on line 10 in Example/Example.ReadSettings/ConsumeService.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net6.0)

Possible null reference argument for parameter 'consumerName' in 'RabbitSubscriber.RabbitSubscriber(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName)'.

Check warning on line 10 in Example/Example.ReadSettings/ConsumeService.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net7.0)

Possible null reference argument for parameter 'consumerName' in 'RabbitSubscriber.RabbitSubscriber(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName)'.

Check warning on line 10 in Example/Example.ReadSettings/ConsumeService.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net7.0)

Possible null reference argument for parameter 'consumerName' in 'RabbitSubscriber.RabbitSubscriber(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName)'.

Check warning on line 10 in Example/Example.ReadSettings/ConsumeService.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net8.0)

Possible null reference argument for parameter 'consumerName' in 'RabbitSubscriber.RabbitSubscriber(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName)'.

Check warning on line 10 in Example/Example.ReadSettings/ConsumeService.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net8.0)

Possible null reference argument for parameter 'consumerName' in 'RabbitSubscriber.RabbitSubscriber(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName)'.
{
_logger = logger;
SetConsumer("FooFirstQueueConsumer");
}

protected override bool HandleMessage(string message)
Expand Down
4 changes: 2 additions & 2 deletions Example/Example.ReadSettings/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
})
.ConfigureServices((context, services) =>
{
services.AutoAddRabbitProducer(context.Configuration);
services.AutoAddRabbitProducer(context.Configuration, false);
services.AutoAddRabbitConsumer(context.Configuration);
// register BackgroundService
services.AddHostedService<PublishService>();
services.AddHostedService<ConsumeService>();
services.AddRabbitSubscriber<ConsumeService>("FooFirstQueueConsumer", true);
});
5 changes: 2 additions & 3 deletions Example/Example.SimpleDI/ConsumeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ namespace Example.SimpleDI;
public class ConsumeService : RabbitSubscriber
{
private readonly ILogger<RabbitSubscriber>? _logger;
public ConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger) : base(consumer, logger)

public ConsumeService(IRabbitConsumer consumer, ILogger<RabbitSubscriber>? logger, string consumerName) : base(consumer, logger, consumerName)
{
_logger = logger;
SetConsumer("FooFirstQueueConsumer");
}

protected override bool HandleMessage(string message)
Expand Down
2 changes: 1 addition & 1 deletion Example/Example.SimpleDI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

// register BackgroundService
builder.Services.AddHostedService<PublishService>();
builder.Services.AddHostedService<ConsumeService>();
builder.Services.AddRabbitSubscriber<ConsumeService>("FooFirstQueueConsumer");

using IHost host = builder.Build();

Expand Down

0 comments on commit b9409fb

Please sign in to comment.