Class JdbcTemplateLockProvider
- java.lang.Object
-
- net.javacrumbs.shedlock.support.StorageBasedLockProvider
-
- net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider
-
- All Implemented Interfaces:
LockProvider
public class JdbcTemplateLockProvider extends StorageBasedLockProvider
Lock provided by JdbcTemplate. It uses a table that contains lock_name and locked_until.- Attempts to insert a new lock record. Since lock name is a primary key, it fails if the record already exists. As an optimization, we keep in-memory track of created lock records.
- If the insert succeeds (1 inserted row) we have the lock.
- If the insert failed due to duplicate key or we have skipped the insertion, we will try to update lock record using UPDATE tableName SET lock_until = :lockUntil WHERE name = :lockName AND lock_until <= :now
- If the update succeeded (1 updated row), we have the lock. If the update failed (0 updated rows) somebody else holds the lock
- When unlocking, lock_until is set to now.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJdbcTemplateLockProvider.ColumnNamesstatic classJdbcTemplateLockProvider.Configuration
-
Constructor Summary
Constructors Constructor Description JdbcTemplateLockProvider(@NotNull DataSource dataSource)JdbcTemplateLockProvider(@NotNull DataSource dataSource, @NotNull String tableName)JdbcTemplateLockProvider(@NotNull JdbcTemplateLockProvider.Configuration configuration)JdbcTemplateLockProvider(@NotNull org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)JdbcTemplateLockProvider(@NotNull org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, @NotNull String tableName)JdbcTemplateLockProvider(@NotNull org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, @Nullable org.springframework.transaction.PlatformTransactionManager transactionManager)JdbcTemplateLockProvider(@NotNull org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, @Nullable org.springframework.transaction.PlatformTransactionManager transactionManager, @NotNull String tableName)
-
-
-
Constructor Detail
-
JdbcTemplateLockProvider
public JdbcTemplateLockProvider(@NotNull @NotNull org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
-
JdbcTemplateLockProvider
public JdbcTemplateLockProvider(@NotNull @NotNull org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, @Nullable @Nullable org.springframework.transaction.PlatformTransactionManager transactionManager)
-
JdbcTemplateLockProvider
public JdbcTemplateLockProvider(@NotNull @NotNull org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, @NotNull @NotNull String tableName)
-
JdbcTemplateLockProvider
public JdbcTemplateLockProvider(@NotNull @NotNull DataSource dataSource)
-
JdbcTemplateLockProvider
public JdbcTemplateLockProvider(@NotNull @NotNull DataSource dataSource, @NotNull @NotNull String tableName)
-
JdbcTemplateLockProvider
public JdbcTemplateLockProvider(@NotNull @NotNull org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, @Nullable @Nullable org.springframework.transaction.PlatformTransactionManager transactionManager, @NotNull @NotNull String tableName)
-
JdbcTemplateLockProvider
public JdbcTemplateLockProvider(@NotNull @NotNull JdbcTemplateLockProvider.Configuration configuration)
-
-