Comments (13)
I am not sure I can help with the current context you provided. The distributed-lock-example
uses spring-web and distributed-lock libraries without any issues I am aware of.
How does your Lock
implementation with Redisson look like?
Did you import DistributedLockConfiguration
using EnableDistributedLock
or with your own alias?
It would be best if you could create a minimal project replicating the issue and posting a link to it here.
from distributed-lock.
OK, I'll create a demo project and post to you a little while.
from distributed-lock.
Sorry that it took me some time to commit my code here in China.
Here is the link of my demo: dl-demo
from distributed-lock.
By the way, distributed-lock-example
is OK because it uses @EnableDistributedLock
which can ensure spring mvc started first and then distributed-lock configuration be loaded.
from distributed-lock.
Sorry for the late response.
There seems to be an issue with the ordering of bean creation for ConversionService
.
Adding a custom bean in the dl-example
projects helps resolve this using:
@Configuration
public class ConversionServiceConfiguration {
@Bean
public ConversionService conversionService() {
return new GenericConversionService();
}
}
I might need to add @AutoConfigureAfter(WebMvcAutoConfiguration.class)
but I need to test that, I am currently a bit short on time unfortunately so I don't know when I will get the chance.
from distributed-lock.
Thx a lot. I can achieve it myself.
from distributed-lock.
Seems that I've tried @AutoConfigureAfter(WebMvcAutoConfiguration.class) several days before, but still failed. I'll confirm it next weekdays.
from distributed-lock.
Sorry, I meant I should include it in distributed-lock-core
so you don't have to :)
from distributed-lock.
I found that if @ConditionalOnMissingBean
annotation wasn't defined on ConversionService
bean, then it works. Seems that if webmvc is integrated, then it fails because of the injection of mvcConversionService
.
I've created a new branch webmvc
for my demo project dl-demo
. It worked OK since i defined a specific conversionService
bean and injected to SpelKeyGenerator
.
Thanks a lot for your help.
from distributed-lock.
But what about others who do not use webmvc? The library should provide a default ConversionService
itself. The problem is in the DistributedLockConfiguration
class, I'll see if I get some time for the weekend to fix and test it.
from distributed-lock.
You're right. But the problem is if other ConversionService
bean defined, then distributed-lock do not work well.
When we use both spring-boot-web and consul, there even will be 2 ConversionService
bean.
I've rewrited DistributedLockConfiguration
class. Here is my code snippet. Hope for your suggestions.
@Bean("conversionService")
@ConditionalOnMissingBean(name = "conversionService")
public ConversionService conversionService() {
return new DefaultConversionService();
}
@Bean("keyGenerator")
@ConditionalOnMissingBean(name = "keyGenerator")
@ConditionalOnBean(ConversionService.class)
public KeyGenerator keyGenerator(@Qualifier("conversionService") final ConversionService conversionService) {
return new StringKeyGenerator(conversionService);
}
from distributed-lock.
Sorry for the late response again. I released a new version (1.4.2) which should resolve your issue. Please, let me know.
from distributed-lock.
Thanks very much. Since I used Spring Boot 2.3.7.Release
, I won't integrate 1.4.2 to my project, but your resolution is pretty good. I've just rewrited a new configuration class to replace the old one and it works well.
from distributed-lock.
Related Issues (20)
- Allow re-entrant code within same Thread? HOT 9
- `scriptExecutor` of `RedisTempate` is null HOT 1
- JDBC lock is not working with MySql due to wrong SQL syntax
- JDBC lock not working with PSQL due to SQL syntax HOT 9
- MongoLocked: Don't retry on "fail to acquire" HOT 2
- Cant create a table with reserved name 'lock' for jdbclock as HOT 1
- Need a hand :) ! HOT 3
- Null lock token versus LockNotAvailableException HOT 4
- "RetriableLock should return null if lock is not acquired after the last retry" - ok.. but why? HOT 2
- RedisLock throws RedisReadOnlyException when using RedisStaticMasterReplicaConfiguration and ReadFrom.REPLICA_PREFERRED HOT 2
- Importing the whole library causes auto wiring issues in Spring Boot HOT 5
- Does it Support Spring Boot 3 ? HOT 7
- Getting Started HOT 2
- Option not to throw exception on lock fail HOT 1
- JDBC Manual Controlled Lock HOT 4
- Testing Annotated Locks HOT 8
- What is the reason behind only using JitPack? HOT 1
- About throwing option added in recent PR HOT 1
- Wrong documentation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from distributed-lock.