ShedLock | Distributed lock for your scheduled tasks | Job Scheduling library

 by   lukas-krecan Java Version: shedlock-parent-5.3.0 License: Apache-2.0

kandi X-RAY | ShedLock Summary

kandi X-RAY | ShedLock Summary

ShedLock is a Java library typically used in Data Processing, Job Scheduling applications. ShedLock has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.

ShedLock makes sure that your scheduled tasks are executed at most once at the same time. If a task is being executed on one node, it acquires a lock which prevents execution of the same task from another node (or thread). Please note, that if one task is already being executed on one node, execution on other nodes does not wait, it is simply skipped. ShedLock uses an external store like Mongo, JDBC database, Redis, Hazelcast, ZooKeeper or others for coordination.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              ShedLock has a medium active ecosystem.
              It has 2953 star(s) with 442 fork(s). There are 70 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 20 open issues and 295 have been closed. On average issues are closed in 106 days. There are 3 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of ShedLock is shedlock-parent-5.3.0

            kandi-Quality Quality

              ShedLock has 0 bugs and 0 code smells.

            kandi-Security Security

              ShedLock has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              ShedLock code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              ShedLock is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              ShedLock releases are not available. You will need to build from source code and install.
              Deployable package is available in Maven.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              ShedLock saves you 6044 person hours of effort in developing the same functionality from scratch.
              It has 15056 lines of code, 1323 functions and 318 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed ShedLock and discovered the below as its top functions. This is intended to give you an instant insight into ShedLock implemented functionality, and help decide if they suit your requirements.
            • Attempt to acquire a lock
            • Try to lock a node
            • Checks if the data is locked
            • Creates a node
            • Attempt to lock the map with the given configuration
            • Add a new lock
            • Try to lock the given configuration
            • Locks document
            • Inserts a document in the database
            • Blocking lock
            • Updates the lock
            • Locks a single lock
            • Intercept the method invocation
            • Creates a simple lock
            • Attempts to create a new lock
            • Creates the parameters from the lock configuration
            • Post process the bean definition registry
            • Creates parameters from a lock configuration
            • Extend a lock
            • Inserts a record in the table
            • Extends the lock
            • Non - blocking lock
            • Updates record
            • Attempts to lock an object
            • Attempts to start a SimpleLock with the given lock configuration
            • Attempts to lock a single object
            Get all kandi verified functions for this library.

            ShedLock Key Features

            No Key Features are available at this moment for ShedLock.

            ShedLock Examples and Code Snippets

            No Code Snippets are available at this moment for ShedLock.

            Community Discussions

            QUESTION

            Spring ShedLock without Database
            Asked 2022-Jan-10 at 12:49

            I want to disable ShedLock with a configuration yml property. So i don't have to create the table shedlock, if it is not necessary. Is there a way to disable Shedlock usage?

            I tried to remove @Bean lockProvider but then I got this message:

            No qualifying bean of type 'net.javacrumbs.shedlock.core.LockProvider

            ...

            ANSWER

            Answered 2022-Jan-10 at 12:49

            If you are using ShedLock in combination with the shedlock-spring dependency, there probably is a @EnableSchedulerLock somewhere in your application. Move the LockProvider bean setup together with the annotation to a separate @Configuration class and add a @ConditionalOnProperty annotation, for example:

            Source https://stackoverflow.com/questions/70651078

            QUESTION

            Shedlock only works on one instance, but not multiple
            Asked 2021-Oct-14 at 09:28

            I would like to setup Shedlock to guard a sensitive process so that only ONE instance of the process ever runs even when multiple application processes are started.

            In my pom.xml

            ...

            ANSWER

            Answered 2021-Oct-14 at 09:22

            You need to add @EnableSchedulerLock to your configuration class as per documents : "In order to enable schedule locking use @EnableSchedulerLock annotation"

            Source https://stackoverflow.com/questions/69565824

            QUESTION

            Shedlock and temporary stop task(s)?
            Asked 2021-Apr-09 at 07:02

            When running several scheduled tasks on multiple servers, Shedlock seems great, but sometimes, we need to halt some of the tasks for a short or long period too. Of course, it is possible to control each task with additional properties/flags, but my suggestion is to use Shedlock for this too, and introduce a logical "node/server" for the task we wish to stop, and update the row in shedlock-table with a lock to this node, and set a lockedAt time in the future, and a lockUntil to future + 1 second (so longer than maxRunning is not triggered). Then it will start again automatically, or we can go in and move the time further into the future if needed.

            Any thoughts on this kind of use for Shedlock... smart or bad practice? It is still used for locking, just locking the job to a logical fake server.

            ...

            ANSWER

            Answered 2021-Apr-09 at 07:02

            It is possible to (mis)use ShedLock for this. The update you are looking for can look like this:

            Source https://stackoverflow.com/questions/67007520

            QUESTION

            Overriding Spring Boot artifact name in Gradle 6.7
            Asked 2021-Apr-06 at 12:22

            Java 8, Spring Boot 2.3.8 and Gradle 6.7 here, and the last time I used Gradle it was on 4.x.

            I created a new Java application using Gradle via:

            ...

            ANSWER

            Answered 2021-Apr-06 at 12:22

            QUESTION

            Sonar: Possible null pointer dereference due to return value of called method
            Asked 2021-Jan-20 at 03:42

            I am getting issue from Sonar: "Style - Possible null pointer dereference due to return value of called method. findbugs:NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE. the issue is on lockUntil.after(new Date());

            ...

            ANSWER

            Answered 2021-Jan-20 at 03:42

            Assuming that new Date() will never return null should be a valid assumption. My guess is that the possibly null value Sonar is complaining about is lockUntil. I assume that queryForObject will return null if the query does not match any rows, so it makes sense that you'd get a complaint about using lockUntil without first checking if it is null.

            Source https://stackoverflow.com/questions/65802608

            QUESTION

            Scraping realtor data with beautifulsoup
            Asked 2020-Nov-30 at 02:40

            I was trying to help out some realtor friends by scraping some data off of realtor.com with beautifulsoup.

            I am trying to get a list of the names and phone numbers of the realtors but am getting each as a separate item and there are duplicates for every realtor on the page.

            This is what I currently have:

            ...

            ANSWER

            Answered 2020-Nov-30 at 02:40

            Well you could use selectors in this way

            Source https://stackoverflow.com/questions/65063940

            QUESTION

            Deadlock while purging old records of spring batch job tables at scheduled time using shedlock
            Asked 2020-Oct-21 at 23:48

            I came across this challenging scenario wherein the transaction gets locked by Microsfoft sql server while executing a batch update query.

            I see this error.

            Transaction (Process ID 293) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Transaction (Process ID 293) was deadlocked on lock resources with another process and has been chosen as the deadlock victim.

            My batch update query:

            ...

            ANSWER

            Answered 2020-Oct-21 at 23:48

            Is LAST_UPDATED from BATCH_STEP_EXECUTION? (I like to put an alias on every column because it's hard to read otherwise.)

            A deadlock will be more likely if it locks more or locks longer. It's important to optimize the query. And if that's not possible, then attempt to use small batch sizes to minimize the size of the transaction.

            The first thing I would do is copy the data to a test environment. The first test I would try is to set the date back far enough to exclude any records. If it's slow, then it's doing a scan. A small batch size is not going to help - it might make it much worse.

            The WHERE clauses with CAST(LAST_UPDATED as date) < DATEADD(day, -7, GETDATE())) covers the column and a table scan will result even if there is an index. Can you compare LAST_UPDATED directly to a local variable of exactly the same type?

            Perhaps check the execution plan. It might indicate a problem.

            Another option is to get the IDs first if they are stable enough. Then do the delete in a separate transaction using the table with the data to delete and perhaps a temp table. I would loop through the delete in batches.

            If the ID an identity column or otherwise monotonically increasing, get the oldest ID to keep. That should be fast. Then delete all that have a smaller ID. (Be sure this is valid logic.)

            Maybe avoid the IN clause? Is this the same result?

            Source https://stackoverflow.com/questions/64469989

            QUESTION

            Java Spring shedlock fails
            Asked 2020-Oct-01 at 12:30

            i have a spring-boot app, which on production environment runs in 2 instances, resulting in scheduled tasks running twice. to avoid that i'm trying use shedlock, as explained here and here, but it has no affect. i'm already using a MySql db, to which i added a shedlock table as explained on both of the examples above.

            my project's structure is as follows (partially) -

            in my application.properties file i have this settings -

            ...

            ANSWER

            Answered 2020-Oct-01 at 12:30

            well, apparently in my big project there was another config class (besides the AppConfig) - one called SqlSpringConfig, inside the db module. once i put the LockProvider bean there, all works like a charm

            Source https://stackoverflow.com/questions/64152064

            QUESTION

            Unable to write unit test for Spring @Scheduler
            Asked 2020-Aug-20 at 15:44

            I have implemented a scheduler with shedlock in my current spring project as follows:

            ...

            ANSWER

            Answered 2020-Aug-20 at 15:44

            This should do the trick LockAssert.TestHelper.makeAllAssertsPass(true);

            Just add it at the beginning of the test method.

            Docs: https://github.com/lukas-krecan/ShedLock#lock-assert

            Source https://stackoverflow.com/questions/63387669

            QUESTION

            Spring Shedlock does not ensure synchronization
            Asked 2020-Jun-19 at 05:36

            I have following scheduled job which runs in multiple instances.

            ...

            ANSWER

            Answered 2020-Jun-18 at 13:13
            interface LockService {
               bool aquireLock(String lockKey, String value);
               bool releaseLock(String lockKey);
            }
            
            interface SomeService {
               void do();
            }
            
            class Scheduler{
                @AutoWired LockService lockService;
                @Autowired SomeService someService;
                @Scheduled(fixedRate = 10000)
                public void awesomeJob() throws InterruptedException {
                  if(lockService.aquireLock("awesomeJob", serverId) ){
                    try{
                       //call service method 
                        someService.do();
                    }catch( Exception e ){
                      //TODO
                    }finally{
                      lockService.releaseLock("awesomeJob");
                    }
                  }   
                }
            }
            

            Source https://stackoverflow.com/questions/62450176

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install ShedLock

            You can download it from GitHub, Maven.
            You can use ShedLock like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the ShedLock component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

            Support

            Help, ShedLock does not do what it’s supposed to do!.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/lukas-krecan/ShedLock.git

          • CLI

            gh repo clone lukas-krecan/ShedLock

          • sshUrl

            git@github.com:lukas-krecan/ShedLock.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Job Scheduling Libraries

            Try Top Libraries by lukas-krecan

            JsonUnit

            by lukas-krecanJava

            future-converter

            by lukas-krecanJava

            json2xml

            by lukas-krecanJava

            completion-stage

            by lukas-krecanJava

            mock-socket

            by lukas-krecanJava