1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

Platform/pm 2535/upgrade to azure messaging servicebus (#3102)

* `dotnet add package Azure.Messaging.ServiceBus` 🤖

* Move to Azure.Messaging.ServiceBus

* `dotnet restore --locked-mode --force-evaluate` 🤖

Remove Microsoft.Azure.ServiceBus

* `dotnet restore --locked-mode --force-evaluate` 🤖

* Include broker filter

* `dotnet restore --locked-mode --force-evaluate` 🤖
This commit is contained in:
Matt Gibson
2023-08-07 09:57:18 -04:00
committed by GitHub
parent 42bf04c46a
commit a5bda60c4e
44 changed files with 2849 additions and 7716 deletions

View File

@ -1,15 +1,16 @@
using Bit.Core.Entities;
using Azure.Messaging.ServiceBus;
using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Repositories;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.Azure.ServiceBus;
namespace Bit.Core.Services;
public class InMemoryServiceBusApplicationCacheService : InMemoryApplicationCacheService, IApplicationCacheService
{
private readonly TopicClient _topicClient;
private readonly ServiceBusClient _serviceBusClient;
private readonly ServiceBusSender _topicMessageSender;
private readonly string _subName;
public InMemoryServiceBusApplicationCacheService(
@ -19,38 +20,38 @@ public class InMemoryServiceBusApplicationCacheService : InMemoryApplicationCach
: base(organizationRepository, providerRepository)
{
_subName = CoreHelpers.GetApplicationCacheServiceBusSubscriptionName(globalSettings);
_topicClient = new TopicClient(globalSettings.ServiceBus.ConnectionString,
globalSettings.ServiceBus.ApplicationCacheTopicName);
_serviceBusClient = new ServiceBusClient(globalSettings.ServiceBus.ConnectionString);
_topicMessageSender = new ServiceBusClient(globalSettings.ServiceBus.ConnectionString).CreateSender(globalSettings.ServiceBus.ApplicationCacheTopicName);
}
public override async Task UpsertOrganizationAbilityAsync(Organization organization)
{
await base.UpsertOrganizationAbilityAsync(organization);
var message = new Message
var message = new ServiceBusMessage
{
Label = _subName,
UserProperties =
Subject = _subName,
ApplicationProperties =
{
{ "type", (byte)ApplicationCacheMessageType.UpsertOrganizationAbility },
{ "id", organization.Id },
}
};
var task = _topicClient.SendAsync(message);
var task = _topicMessageSender.SendMessageAsync(message);
}
public override async Task DeleteOrganizationAbilityAsync(Guid organizationId)
{
await base.DeleteOrganizationAbilityAsync(organizationId);
var message = new Message
var message = new ServiceBusMessage
{
Label = _subName,
UserProperties =
Subject = _subName,
ApplicationProperties =
{
{ "type", (byte)ApplicationCacheMessageType.DeleteOrganizationAbility },
{ "id", organizationId },
}
};
var task = _topicClient.SendAsync(message);
var task = _topicMessageSender.SendMessageAsync(message);
}
public async Task BaseUpsertOrganizationAbilityAsync(Organization organization)