Giter Site home page Giter Site logo

Need a help about distributed-lock HOT 13 CLOSED

alturkovic avatar alturkovic commented on September 25, 2024
Need a help

from distributed-lock.

Comments (13)

alturkovic avatar alturkovic commented on September 25, 2024

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.

selwynshen avatar selwynshen commented on September 25, 2024

OK, I'll create a demo project and post to you a little while.

from distributed-lock.

selwynshen avatar selwynshen commented on September 25, 2024

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.

selwynshen avatar selwynshen commented on September 25, 2024

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.

alturkovic avatar alturkovic commented on September 25, 2024

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.

selwynshen avatar selwynshen commented on September 25, 2024

Thx a lot. I can achieve it myself.

from distributed-lock.

selwynshen avatar selwynshen commented on September 25, 2024

Seems that I've tried @AutoConfigureAfter(WebMvcAutoConfiguration.class) several days before, but still failed. I'll confirm it next weekdays.

from distributed-lock.

alturkovic avatar alturkovic commented on September 25, 2024

Sorry, I meant I should include it in distributed-lock-core so you don't have to :)

from distributed-lock.

selwynshen avatar selwynshen commented on September 25, 2024

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.

alturkovic avatar alturkovic commented on September 25, 2024

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.

selwynshen avatar selwynshen commented on September 25, 2024

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.

alturkovic avatar alturkovic commented on September 25, 2024

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.

selwynshen avatar selwynshen commented on September 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.