Skip to content

Commit

Permalink
moved consumers back into the webapp
Browse files Browse the repository at this point in the history
azure container apps is too slow for now (30 sec polling time is an issue)
  • Loading branch information
NielsPilgaard committed Oct 17, 2023
1 parent b00cdd2 commit 8e6aeb4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ public static WebApplicationBuilder AddMassTransit(this WebApplicationBuilder bu
{
builder.Services.AddMassTransit(config =>
{
config.AddConsumer<StartChatConsumer>();
config.AddConsumer<SendMessageConsumer>();
config.AddConsumer<SetChatNameConsumer>();
config.UsingAzureServiceBus((context, azureServiceBus) =>
{
azureServiceBus.Host(builder.Configuration.GetConnectionString("AzureServiceBus"));
Expand Down
14 changes: 14 additions & 0 deletions src/web/Server/Consumers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Info

All consumers in this folders should be moved to Azure Container Apps or
Azure Container App Jobs once Mini Møder's traffic is large enough.

## Criteria

**ChatConsumers:**

- Over 1 message sent every 5 minutes, consistently throughout the day (6-24)

OR

- Over 100 messages sent per hour, consistently throughout the day (6-24)
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Jordnaer.Server.Database;
using Jordnaer.Shared;
using MassTransit;
using Microsoft.EntityFrameworkCore;

namespace Jordnaer.Chat;
namespace Jordnaer.Server.Consumers;

public class SendMessageConsumer : IConsumer<SendMessage>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Jordnaer.Shared;
using MassTransit;

namespace Jordnaer.Chat;
namespace Jordnaer.Server.Consumers;

public class SetChatNameConsumer : IConsumer<SetChatName>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using Jordnaer.Server.Database;
using Jordnaer.Shared;
using MassTransit;

namespace Jordnaer.Chat;
namespace Jordnaer.Server.Consumers;

public class StartChatConsumer : IConsumer<StartChat>
{
Expand All @@ -16,7 +17,7 @@ public async Task Consume(ConsumeContext<StartChat> consumeContext)
{
var chat = consumeContext.Message;

_context.Chats.Add(new Shared.Chat
_context.Chats.Add(new Chat
{
LastMessageSentUtc = chat.LastMessageSentUtc,
Id = chat.Id,
Expand Down
5 changes: 5 additions & 0 deletions src/web/Server/Extensions/WebApplicationBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Jordnaer.Server.Consumers;
using Jordnaer.Server.Database;
using MassTransit;
using Microsoft.AspNetCore.ResponseCompression;
Expand All @@ -11,6 +12,10 @@ public static WebApplicationBuilder AddMassTransit(this WebApplicationBuilder bu
{
builder.Services.AddMassTransit(config =>
{
config.AddConsumer<StartChatConsumer>();
config.AddConsumer<SendMessageConsumer>();
config.AddConsumer<SetChatNameConsumer>();
config.UsingAzureServiceBus((context, azureServiceBus) =>
{
azureServiceBus.Host(builder.Configuration.GetConnectionString("AzureServiceBus"));
Expand Down

0 comments on commit 8e6aeb4

Please sign in to comment.