Can I check it remotely? you can contact me on WeChat.
other third-party systems
This is not an ABP project, right?
You can directly use the RabbitMQ class library https://www.nuget.org/packages/RabbitMQ.Client . instead of AbpEventBusRabbitMqModule
Hi,
How do I reproduce the problem?
Or can you share a test project with me? i will check it. shiwei.liang@volosoft.com
Can you describe your use case?
distributed event bus works in-process by default, My project is not a microservices project
When using AbpEventBusRabbitMqModule
, it will be replaced with the RabbitMQ event bus.
Hi,
You can try this:
Configure<AuthorizationOptions>(options =>
{
options.AddPolicy("TestPermission1_And_TestPermission2", policy =>
{
policy.Requirements.Add(new PermissionsRequirement(["TestPermission1", "TestPermission2"], requiresAll: true));
});
options.AddPolicy("TestPermission1_Or_TestPermission2", policy =>
{
policy.Requirements.Add(new PermissionsRequirement(new []{"TestPermission1", "TestPermission2"}, requiresAll: false));
});
});
[Authorize("TestPermission1_And_TestPermission2")]
.....
[Authorize("TestPermission1_Or_TestPermission2")]
HI,
If you don't need RabbitMQ distributed event bus, please remove AbpEventBusRabbitMqModule
Hi,
You can try to override the RabbitMqDistributedEventBus
and set ConsumerDispatchConcurrency
For example:
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IDistributedEventBus), typeof(RabbitMqDistributedEventBus), typeof(IRabbitMqDistributedEventBus))]
public class MyRabbitMqDistributedEventBus : RabbitMqDistributedEventBus
{
protected List<IRabbitMqMessageConsumer> Consumers { get; private set; } = default!;
public override Initialize()
{
// create consumers
Consumers = new List....
for(var i=0; i<3; i++)
{
Consumers.Add(MessageConsumerFactory.Create(
new ExchangeDeclareConfiguration(
AbpRabbitMqEventBusOptions.ExchangeName,
type: AbpRabbitMqEventBusOptions.GetExchangeTypeOrDefault(),
durable: true,
arguments: AbpRabbitMqEventBusOptions.ExchangeArguments
),
new QueueDeclareConfiguration(
AbpRabbitMqEventBusOptions.ClientName,
durable: true,
exclusive: false,
autoDelete: false,
prefetchCount: AbpRabbitMqEventBusOptions.PrefetchCount,
arguments: AbpRabbitMqEventBusOptions.QueueArguments
),
AbpRabbitMqEventBusOptions.ConnectionName
);
)
}
foreach(var consumer in Consumers)
{
consumer.OnMessageReceived(ProcessEventAsync);
}
SubscribeHandlers(AbpDistributedEventBusOptions.Handlers);
}
public override IDisposable Subscribe(Type eventType, IEventHandlerFactory factory)
{
var handlerFactories = GetOrCreateHandlerFactories(eventType);
if (factory.IsInFactories(handlerFactories))
{
return NullDisposable.Instance;
}
handlerFactories.Add(factory);
if (handlerFactories.Count == 1) //TODO: Multi-threading!
{
foreach(var consumer in Consumers)
{
Consumer.BindAsync(EventNameAttribute.GetNameOrDefault(eventType));
}
}
return new EventHandlerFactoryUnregistrar(this, eventType, factory);
}
}
Hi,
Is your RabbitMQ server available?
You can try using docker to create a Rabbitmq container
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:4.0-management
Update appsettings.json:
{
"RabbitMQ": {
"EventBus": {
"ClientName": "MyClientName",
"ExchangeName": "MyExchangeName"
}
}
}
Hi,
Is there a preferred way to handle this without relying on HttpContextAccessor?
It's best practice to get the current user token from the current http context
I can't reproduce the problem.
My steps:
abp new Testapp -u blazor-server
ObjectExtensionManager.Instance.Modules()
.ConfigureIdentity(identity =>
{
identity.ConfigureUser(user =>
{
user.AddOrUpdateProperty<int?>(
"SupplierId",
property =>
{
property.UI.Lookup.Url = "/api/app/suppliers";
property.UI.Lookup.DisplayPropertyName = "companyName";
}
);
});
});
[Authorize]
[Route("api/app/suppliers")]
public class SuppliersController : AbpController
{
[Route("")]
public ListResultDto<TestDto> GetAsync()
{
return new ListResultDto<TestDto>(
new[]
{
new TestDto
{
Id = 1,
CompanyName = "Apple"
},
new TestDto
{
Id = 2,
CompanyName = "Microsoft"
}
}
);
}
}
public class TestDto
{
public string CompanyName { get; set; }
public int Id { get; set; }
}
Hi
I just simply check the logs, (because it’s too late now)
It looks like a cache avalanche, and a large number of requests to query the database caused timeout.
You can try
1 Increase cache expiration time 2 Increase database timeout