- ABP Framework version: 7.1.1
- UI Type: **Angular **/ MVC / Blazor WASM / Blazor Server
- Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..) / MongoDB
- Tiered (for MVC) or Auth Server Separated (for Angular): yes/no
- Exception message and full stack trace:
- Steps to reproduce the issue:
Hi, To include the Lock system in our project, we followed the procedures in the Distributed Locking document provided to us by ABP. https://docs.abp.io/en/abp/latest/Distributed-Locking The following operations were performed; 1-First of all, we added the Volo.Abp.DistributedLocking package to our project from the Nuget Package Manager. https://prnt.sc/v60w6NZd2fG1 2- In the next step, the necessary configuration adjustments were made in the HttpApiHostModule.cs class in the project. https://prnt.sc/g-WBBlUUEMye To prevent errors on the RedisDistributedSynchronizationProvider class, “DistributedLock.Redis” package was downloaded with version 1.0.2. 3- In the next step, we implemented the “IAbpDistributedLock” interface in our method. https://prnt.sc/TNF6wAJeo-i9 However, when we run the above method and want to test Distributed Lock, the method does not work correctly and we get the following error; https://prnt.sc/1PipGiS1htFc
11 Answer(s)
-
0
Hi,
I will check it
-
0
-
0
-
0
Hello, The problem continues. Could you please let me know a time you have available? We want to demonstrate the problem on the spot by organizing meetings such as Zoom, Teams, Meet.
-
0
Ok, join the meeting: https://us05web.zoom.us/j/84476788133?pwd=OexABNPrNizuDNTc4uE9Aswo60Wnun.1
-
0
What hours are you available today? Let's schedule a meeting for today.
-
0
Hi,
I'm available now.
-
0
Hi,
I'm available now.
I scheduled a meeting for 20 minutes later. The Meeting Link should have arrived in your e-mail address. Thank you.
-
0
Hi,
Will it work if you install the
StackExchange.Redis
version2.7.4
to theHttpApi.Host
project? -
0
Hi, Thank you for your support, the lock system is working. However, we made it usable as I shared in the screenshot. We need to use it in all entities in our project as create and update, which causes code repetition. I wonder if you have a solution for this?
Note: The reason we need this code is that when the method is run more than once at the same time, it registers to the database without going through validations.
-
0
Hi,
Do not throw exceptions, this may cause the lock to not be released
We need to use it in all entities in our project as create and update, which causes code repetition. I wonder if you have a solution for this?
You can create a generic domain service:
public class LockEntityManager<TEntity> where TEntity: .... , ITransientDependency { private readonly IRepository<TEntity> _reopsitory; private readonly IAbpDistributedLock _distributedLock; private readonly IEntityCheck<TEntity> _entityCheck; ... public async Task<TEntity> CreateAsync(TEntity entity, string lockName) { await using (var handle = await _distributedLock.TryAcquireAsync(lockName)) { if (handle != null) { await _entityCheck.CreateValidAsync(entity); ..... } } } public async Task<TEntity> UpdateAsync(TEntity entity, string lockName) { ..... } } public interface IEntityCheck<TEntity> where TEntity: .... { Task CreateValidAsync(Tentity entity); Task UpdateValidAsync(Tentity entity); } public class TestEntityCheck : IEntityCheck<Test>, ITransientDependency { ..... } public class TestAppService : ... { private readonly LockEntityManager<Test> _testEntityManager; .... }