safe-scheduling-provider-mongodb

it's a simple way to use the native Spring Framework Scheduling into your spring-boot application keeping the tasks locked during the executions process avoiding multiples executions.

License

License

Categories

Categories

IDE Development Tools MongoDB Data Databases
GroupId

GroupId

io.github.nortthon
ArtifactId

ArtifactId

safe-scheduling-provider-mongodb
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

safe-scheduling-provider-mongodb
it's a simple way to use the native Spring Framework Scheduling into your spring-boot application keeping the tasks locked during the executions process avoiding multiples executions.

Download safe-scheduling-provider-mongodb

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.nortthon/safe-scheduling-provider-mongodb/ -->
<dependency>
    <groupId>io.github.nortthon</groupId>
    <artifactId>safe-scheduling-provider-mongodb</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.nortthon/safe-scheduling-provider-mongodb/
implementation 'io.github.nortthon:safe-scheduling-provider-mongodb:0.2.0'
// https://jarcasting.com/artifacts/io.github.nortthon/safe-scheduling-provider-mongodb/
implementation ("io.github.nortthon:safe-scheduling-provider-mongodb:0.2.0")
'io.github.nortthon:safe-scheduling-provider-mongodb:jar:0.2.0'
<dependency org="io.github.nortthon" name="safe-scheduling-provider-mongodb" rev="0.2.0">
  <artifact name="safe-scheduling-provider-mongodb" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.nortthon', module='safe-scheduling-provider-mongodb', version='0.2.0')
)
libraryDependencies += "io.github.nortthon" % "safe-scheduling-provider-mongodb" % "0.2.0"
[io.github.nortthon/safe-scheduling-provider-mongodb "0.2.0"]

Dependencies

compile (1)

Group / Artifact Type Version
io.github.nortthon : safe-scheduling-core jar 0.2.0

provided (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-data-mongodb jar 2.1.3.RELEASE
org.springframework : spring-context jar 5.1.4.RELEASE
org.projectlombok : lombok jar 1.18.4

test (2)

Group / Artifact Type Version
de.flapdoodle.embed : de.flapdoodle.embed.mongo jar 2.1.2
org.springframework.boot : spring-boot-starter-test jar 2.1.3.RELEASE

Project Modules

There are no modules declared in this project.

Safe Scheduling

License Actions Status Quality Gate Status Maintainability Rating Coverage

What is this?

it's a simple way to use the native Spring Framework Scheduling into your spring-boot application keeping the tasks locked during the executions process avoiding multiples executions.

TaskScheduler Bean

@Configuration
@EnableScheduling
public class SchedulerConfig {
    
    @Bean
    public TaskScheduler taskScheduler(final Provider provider) {
        final LockableTaskScheduler taskScheduler = new LockableTaskScheduler(provider);
        taskScheduler.setPoolSize(1); // Default == 1
        return taskScheduler;
    }
    
    //Provider Bean
}

Use like this

@Component
public class Class {
    @SafeScheduled(name = "scheduler-name", lockedFor = 4000L, cron = "*/5 * * * * *")
    public void execute() {
        //TODO
    }
}

MongoDB Provider

Dependences
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
    <groupId>io.github.nortthon</groupId>
    <artifactId>safe-scheduling-provider-mongodb</artifactId>
    <version>0.2.0</version>
</dependency>
Provider Bean
@Bean
public Provider provider(final MongoTemplate mongoTemplate) {
    new MongoProvider(mongoTemplate);
}

Redis Provider

Dependences
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
    <groupId>io.github.nortthon</groupId>
    <artifactId>safe-scheduling-provider-redis</artifactId>
    <version>0.2.0</version>
</dependency>
Provider Bean
@Bean
public Provider provider(final StringRedisTemplate redisTemplate) {
    new RedisProvider(redisTemplate);
}

Versions

Version
0.2.0
0.1.1
0.1.0