Skip to content

Commit bb7eb80

Browse files
author
Paul HAMADOU
committed
first commit
1 parent 7c15cea commit bb7eb80

File tree

10 files changed

+613
-30
lines changed

10 files changed

+613
-30
lines changed

ApiConsumerProduct/src/ApiConsumerProduct/ApiConsumerProduct.WebApi.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ApiConsumerProduct/src/ApiConsumerProduct/Domain/DomainDirectory/Features/ CreatedProductConsumer.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ namespace ApiConsumerProduct.Domain.DomainDirectory.Features;
77
public sealed class CreatedProductConsumer() : IConsumer<ICreatedProductMessage>
88
{
99
public Task Consume(ConsumeContext<ICreatedProductMessage> context)
10-
{
11-
// do work here
12-
13-
return Task.CompletedTask;
10+
{
11+
// do work here
12+
var product = context.Message;
13+
14+
Console.WriteLine($"Received CreatedProductMessage: ProductId={product.ProductId}, Price={product.Price}, Description={product.Description}, Quantity={product.Quantity}");
15+
16+
return Task.CompletedTask;
1417
}
1518
}

ApiConsumerProduct/src/ApiConsumerProduct/Extensions/Services/ConsumerRegistrations/CreatedProductCusumerEndpointRegistrationRegistration.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ public static class CreatedProductCusumerEndpointRegistrationRegistration
99
{
1010
public static void CreatedProductCusumerEndpointRegistration(this IRabbitMqBusFactoryConfigurator cfg, IBusRegistrationContext context)
1111
{
12-
cfg.ReceiveEndpoint("created-generation-product-queue", re =>
12+
cfg.ReceiveEndpoint(Environment.GetEnvironmentVariable("RMQ_QUEUE_NAME"), re =>
1313
{
1414
// turns off default fanout settings
1515
re.ConfigureConsumeTopology = false;
1616

1717
// a replicated queue to provide high availability and data safety. available in RMQ 3.8+
18-
re.SetQuorumQueue();
18+
// re.SetQuorumQueue();
1919

2020
// enables a lazy queue for more stable cluster with better predictive performance.
2121
// Please note that you should disable lazy queues if you require really high performance, if the queues are always short, or if you have set a max-length policy.
2222
re.SetQueueArgument("declare", "lazy");
2323

2424
// the consumers that are subscribed to the endpoint
25-
re.ConfigureConsumer< CreatedProductConsumer>(context);
25+
re.ConfigureConsumer<CreatedProductConsumer>(context);
2626

2727
// the binding of the intermediary exchange and the primary exchange
2828
re.Bind("created-generation-product-exchange", e =>

ApiConsumerProduct/src/ApiConsumerProduct/Extensions/Services/InfrastructureServiceExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public static void AddInfrastructure(this IServiceCollection services, IWebHostE
2121
{
2222
// this makes local migrations easier to manage. feel free to refactor if desired.
2323
connectionString = env.IsDevelopment()
24-
? "Host=localhost;Port=57122;Database=dev_dockerconfig;Username=SA;Password=#localDockerPassword#"
25-
: throw new Exception("The database connection string is not set.");
24+
? "Host=localhost;Port=5432;Database=db-consumer-product;Username=postgres;Password=admin"
25+
: throw new Exception("The database connection string is not set.");
2626
}
2727

2828
services.AddDbContext<ConsumerProductDbContext>(options =>

ApiConsumerProduct/src/ApiConsumerProduct/Extensions/Services/MassTransitServiceExtension.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ public static void AddMassTransitServices(this IServiceCollection services, IWeb
2626
mt.AddConsumers(Assembly.GetExecutingAssembly());
2727
mt.UsingRabbitMq((context, cfg) =>
2828
{
29-
cfg.Host(rmqOptions.Host,
30-
ushort.Parse(rmqOptions.Port),
31-
rmqOptions.VirtualHost,
32-
h =>
33-
{
34-
h.Username(rmqOptions.Username);
35-
h.Password(rmqOptions.Password);
36-
});
29+
cfg.Host(Environment.GetEnvironmentVariable("RMQ_HOST"),
30+
ushort.Parse(Environment.GetEnvironmentVariable("RMQ_PORT")),
31+
Environment.GetEnvironmentVariable("RMQ_VIRTUAL_HOST"),
32+
h =>
33+
{
34+
h.Username(Environment.GetEnvironmentVariable("RMQ_USERNAME"));
35+
h.Password(Environment.GetEnvironmentVariable("RMQ_PASSWORD"));
36+
});
3737

38-
// Producers -- Do Not Delete This Comment
38+
// Producers -- Do Not Delete This Comment
3939

40-
// Consumers -- Do Not Delete This Comment
41-
cfg.CreatedProductCusumerEndpointRegistration(context);
40+
// Consumers -- Do Not Delete This Comment
41+
cfg.CreatedProductCusumerEndpointRegistration(context);
4242
});
4343
});
4444
services.AddOptions<MassTransitHostOptions>();

ApiConsumerProduct/src/ApiConsumerProduct/Migrations/20251019154915_initialMigration.Designer.cs

Lines changed: 224 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)