-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ali Karaca
committed
Apr 22, 2022
1 parent
e38bc88
commit fcb90e6
Showing
17 changed files
with
59 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using MassTransit; | ||
using MasstransitDemo.Shared; | ||
using System.Text.Json; | ||
|
||
namespace MasstransitDemo.Consumer; | ||
|
||
public class NotificationCreatedConsumer : IConsumer<INotificationCreated> | ||
{ | ||
public async Task Consume(ConsumeContext<INotificationCreated> context) | ||
{ | ||
var serializedMessage = JsonSerializer.Serialize(context.Message, new JsonSerializerOptions { }); | ||
|
||
Console.WriteLine($"NotificationCreated event consumed. Message: {serializedMessage}"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
using MassTransit; | ||
using MasstransitDemo.Consumer; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using System.Reflection; | ||
|
||
var builder = Host.CreateDefaultBuilder(args); | ||
|
||
builder.ConfigureServices((hostContext, services) => | ||
{ | ||
services.AddSingleton<INotificationProcessor, NotificationProcessor>(); | ||
services.AddSingleton<IConsumeObserver, ConsumeObserver>(); | ||
services.AddMassTransit(busConfigurator => | ||
{ | ||
var entryAssembly = Assembly.GetExecutingAssembly(); | ||
busConfigurator.AddConsumers(entryAssembly); | ||
busConfigurator.UsingRabbitMq((context, busFactoryConfigurator) => | ||
{ | ||
busConfigurator.SetKebabCaseEndpointNameFormatter(); | ||
busFactoryConfigurator.Host("rabbitmq", h => { }); | ||
busFactoryConfigurator.Host("rabbitmq", "/", h => { }); | ||
busFactoryConfigurator.ConfigureEndpoints(context); | ||
busFactoryConfigurator.ConnectConsumeObserver(context.GetRequiredService<IConsumeObserver>()); | ||
}); | ||
}); | ||
}); | ||
|
||
var app = builder.Build(); | ||
|
||
app.Run(); | ||
app.Run(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace MasstransitDemo.Shared; | ||
|
||
public interface INotificationCreated | ||
{ | ||
DateTime NotificationDate { get; } | ||
string NotificationMessage { get; } | ||
NotificationType NotificationType { get; } | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
namespace MasstransitDemo.Shared | ||
namespace MasstransitDemo.Shared; | ||
|
||
public enum NotificationType | ||
{ | ||
public enum NotificationType | ||
{ | ||
Email, | ||
Push, | ||
Sms | ||
} | ||
Email, | ||
Push, | ||
Sms | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters