Giter Site home page Giter Site logo

Comments (5)

alturkovic avatar alturkovic commented on July 19, 2024

There is manual acquire, take a look at this. This way you have complete control over the locks.

But I think setting the @Locked(timeout = @Interval("0")) should also work. If not, I'll definitely add a way to bypass the retry mechanism through the annotation.

Please let me know if you manage to do it :)

P.S. Did you close because you managed to do it yourself?

from distributed-lock.

AndreaAdvanon avatar AndreaAdvanon commented on July 19, 2024

I closed it because this was not actually the problem 😄
I notice that the annotation to work must be placed in a method that is called from another class, not the current one.
Like:

@Service
class MyService {
   
   fun doSomeThing() = doThing() // Not working here   

   @JdbcLocked
   fun doThing() = "thing"
}

@Service
class MyOtherService(private val myService: MyService) {
    fun doSomeThing() = myService.doThing() // Works here
}

Is there a way around it besides using the manual lock?

from distributed-lock.

alturkovic avatar alturkovic commented on July 19, 2024

Well that is the way proxies and local method calls work. When your method calls a local method, you bypass the proxy and thus the annotation is useless. I'm sure there are way better explanations available online. Glad to hear you solved the issue :)

from distributed-lock.

alturkovic avatar alturkovic commented on July 19, 2024

I was actually trying to explain self-invocation, take a look at the official doc here: https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#aop-understanding-aop-proxies (sorry about formatting, I'm on mobile)

from distributed-lock.

AndreaAdvanon avatar AndreaAdvanon commented on July 19, 2024

Yes this is what I thought, thanks!

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.