A peek into Atoti Limits’s new persistence feature
With the latest 3.3 release, we’ve upgraded from just persisting limits and their incidents to CSV files; now, we can also persist them to an external database. Let’s dive into how this new feature works and how we can configure it.
For more details, read our documentation. For more blogs on this and other products or features, check out atoti.io.
Atoti Limits Datasources
We can configure Atoti Limits to connect to the following data sources:
- The Limits Application Datasource: Stores tables for limit structures, limits, and incidents. Use the property prefix
limits.application.datasource
to define this. - The Limits Workflow Datasource: Stores tables required by the workflow-core module. Use the property prefix
application.datasource
to define this. - The Activiti Datasource: Stores tables required by Activiti runtime, a lightweight workflow and Business Process Management (BPM) platform. Use the property prefix
activiti.datasource
to define this. - The Activiti Audit Log Datasource: Stores tables required by the Activiti audit log. It’s defined using the property prefix
audit-log.datasource
.
For more details on extending the persistence services, check out the Adding Custom Persistence Services.
Configuration
Atoti Limits offers services for managing objects at runtime. Here’s how we can set things up:
Managed Objects
We manage three types of objects in Atoti Limits:
- Limit Structures: Frameworks that define various types of limits within the system.
- Limits: Specific restrictions or thresholds applied to data or processes.
- Incidents: Events or occurrences that need to be tracked and managed.
These objects can be loaded from an external database, managed within Atoti Limits, and any changes will sync with the external database. To work with persistent data, we need to specify the load mode and configure the connection to the external datasource.
Specifying the Load Mode
We can choose one of three modes to load data into Atoti Limits:
- CSV Load Mode: The default mode. Load data from CSV files, as in previous versions. No need to configure the external datasource. To explicitly enable it, set
limits.data.mode=csv
. - Persistent Load Mode: For working with persistent data. Load data from an external database using JPA (Java Persistence API), specifically Spring’s Data JPA. To use this mode:
- Enable it by settinglimits.data.mode=persistent
.
- Configure the external datasource. - CSV to Persistent Load Mode: Used to migrate limits from CSV sources to the external database. For more information, see Limits Data Migration.
Configuring the Connection to the External Datasource
To connect to an external datasource, we can configure the connection using properties. Below are the default properties:
limits:
application:
datasource:
url: "jdbc:h2:mem:limits-application;DB_CLOSE_DELAY=-1;"
username: app
password:
properties:
hibernate:
dialect: org.hibernate.dialect.H2Dialect
format_sql: true
hbm2ddl:
auto: update
globally_quoted_identifiers: true
hikari:
connectionTimeout: 30000
idleTimeout: 60000
minimumIdle: 1
maximumPoolSize: 10
poolName: "limits-application"
For further details on extending persistence in Atoti Limits, see Adding Custom Persistence.