Skip to content

Commit

Permalink
Merge pull request #74 from TunNetCom/Fix-publish-problem
Browse files Browse the repository at this point in the history
Fix infenity loop
  • Loading branch information
MarwenSaad authored Dec 14, 2024
2 parents 3b16425 + 20758e1 commit a6d07dc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ await _userProfileApiClient.GeUserOrganizations(

adminInfoResponse.AsT0.UserAccount = organizationResponce.AsT0;

// await endpoint.Send(adminInfoResponse.AsT0, cancellationToken);
await _publishEndpoint.Publish(adminInfoResponse.AsT0);
await _publishEndpoint.Publish(adminInfoResponse.AsT0, context =>
{
context.SetRoutingKey("user.profile.routing.key");
});
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

using AzureDevopsService.Contracts.AzureResponceModel;
using IdentityService.Application.Features.MessageBroker.Consumer;
using IdentityService.Contracts.Settings;
using MassTransit;
Expand All @@ -14,7 +15,7 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection
_ = services.AddMassTransit(x =>
{
x.SetDefaultEndpointNameFormatter();
_ = x.AddConsumer<AzureDevopsConsumer>();
_ = x.AddConsumer<IdentityConsumer>();
x.SetDefaultEndpointNameFormatter();

x.UsingRabbitMq((context, cfg) =>
Expand All @@ -29,10 +30,10 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection

cfg.UseNewtonsoftJsonSerializer();

cfg.ReceiveEndpoint("ProfileUserResponce", e =>
cfg.ReceiveEndpoint("identity-service-queue", e =>
{
e.SetQueueArgument("x-message-ttl", 60000);
e.ConfigureConsumer<AzureDevopsConsumer>(context);
e.UseMessageRetry(r => r.Interval(3, TimeSpan.FromSeconds(5)));
e.ConfigureConsumer<IdentityConsumer>(context);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

namespace IdentityService.Application.Features.MessageBroker.Consumer
{
public class AzureDevopsConsumer(UserManager<ApplicationUser> userManager, AuthContext authContext, ILogger<AzureDevopsConsumer> logger) :
public class IdentityConsumer(UserManager<ApplicationUser> userManager, AuthContext authContext, ILogger<IdentityConsumer> logger) :
IConsumer<UserProfile>,
IConsumer<CustomProblemDetailsResponce>
{
private readonly UserManager<ApplicationUser> _userManager = userManager;
private readonly AuthContext _authContext = authContext;
private readonly ILogger<AzureDevopsConsumer> _logger = logger;
private readonly ILogger<IdentityConsumer> _logger = logger;

public async Task Consume(ConsumeContext<UserProfile> context)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AzureDevopsService.Contracts.AzureRequestResourceModel;
using AzureDevopsService.Contracts.AzureRequestModel;
using AzureDevopsService.Contracts.AzureRequestResourceModel;
using MassTransit;
using System;
using System.Collections.Generic;
Expand All @@ -17,7 +18,7 @@ public async Task Handle(ProfileAzureUserCommand request, CancellationToken canc
{
ISendEndpoint endpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri("rabbitmq://rabbitmq/AzureDevops"));

BaseRequest azureRequest = new()
AzureAdminInfoRequest azureRequest = new()
{
Email = request.Email,
Path = request.Path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AzureDevopsService.Contracts" Version="1.0.4" />
<PackageReference Include="AzureDevopsService.Contracts" Version="1.0.5" />
<PackageReference Include="MassTransit" Version="8.3.2" />
<PackageReference Include="MassTransit.Abstractions" Version="8.3.2" />
<PackageReference Include="MassTransit.Extensions.DependencyInjection" Version="7.3.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection
e.ConfigureConsumer<CodeEventsConsumer>(context);
e.UseMessageRetry(r => r.Interval(3, TimeSpan.FromSeconds(5)));
});
config.ReceiveEndpoint("ProfileUserResponce", e =>
config.ReceiveEndpoint("timelog-service-queue", e =>
{
e.SetQueueArgument("x-message-ttl", 60000);
e.ConfigureConsumer<ProfileUserConsumer>(context);
e.UseMessageRetry(r => r.Interval(3, TimeSpan.FromSeconds(5)));
});
Expand Down

0 comments on commit a6d07dc

Please sign in to comment.