FINERACT-1744 - Idempotency support

- [x] Idempotency write move to filters
- [x] Idempotency integration test with success and failure
- [x] Added response status code to database
- [x] SynchronousCommandProcessingService not generate the command, just marked to the filter
- [x] IdempotencyStoreFilter store the command request if available.
- [x] Removed JpaExceptionHandler.java
This commit is contained in:
Janos Haber
2022-11-28 12:04:03 +01:00
committed by Arnold Gálovics
parent 25c0b6a08d
commit 5210bf7412
46 changed files with 1428 additions and 166 deletions
@@ -130,6 +130,7 @@ spring.datasource.hikari.idleTimeout=${FINERACT_HIKARI_IDLE_TIMEOUT:60000}
spring.datasource.hikari.connectionTimeout=${FINERACT_HIKARI_CONNECTION_TIMEOUT:20000}
spring.datasource.hikari.connectionTestquery=${FINERACT_HIKARI_TEST_QUERY:SELECT 1}
spring.datasource.hikari.autoCommit=${FINERACT_HIKARI_AUTO_COMMIT:true}
spring.datasource.hikari.transactionIsolation=${FINERACT_HIKARI_TRANSACTION_ISOLATION:TRANSACTION_REPEATABLE_READ}
spring.datasource.hikari.dataSourceProperties['cachePrepStmts']=${FINERACT_HIKARI_DS_PROPERTIES_CACHE_PREP_STMTS:true}
spring.datasource.hikari.dataSourceProperties['prepStmtCacheSize']=${FINERACT_HIKARI_DS_PROPERTIES_PREP_STMT_CACHE_SIZE:250}
spring.datasource.hikari.dataSourceProperties['prepStmtCacheSqlLimit']=${FINERACT_HIKARI_DS_PROPERTIES_PREP_STMT_CACHE_SQL_LIMIT:2048}
@@ -91,4 +91,7 @@
<include file="parts/0069_add_unique_constraint_for_reversal_external_id_of_loan_transactions.xml" relativeToChangelogFile="true"/>
<include file="parts/0070_add_event_configuration_for_delinquency_range_change_event.xml" relativeToChangelogFile="true"/>
<include file="parts/0071_add_external_id_support_for_loan_transaction.xml" relativeToChangelogFile="true"/>
<include file="parts/0072_add_result_and status_to_command_source.xml" relativeToChangelogFile="true" />
<include file="parts/0073_add_result_status_code_to_command_source.xml" relativeToChangelogFile="true" />
</databaseChangeLog>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
<changeSet id="1" author="fineract" context="postgresql">
<renameColumn newColumnName="status"
oldColumnName="processing_result_enum"
tableName="m_portfolio_command_source"/>
</changeSet>
<changeSet id="2" author="fineract" context="mysql">
<renameColumn newColumnName="status"
oldColumnName="processing_result_enum"
tableName="m_portfolio_command_source"
columnDataType="smallint(6)" />
</changeSet>
<changeSet id="3" author="fineract">
<addColumn tableName="m_portfolio_command_source">
<column name="result" type="TEXT"/>
</addColumn>
</changeSet>
</databaseChangeLog>
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
<changeSet id="1" author="fineract" context="postgresql">
<addColumn tableName="m_portfolio_command_source">
<column name="result_status_code" type="int"></column>
</addColumn>
</changeSet>
<changeSet id="2" author="fineract" context="mysql">
<addColumn tableName="m_portfolio_command_source">
<column name="result_status_code" type="int"></column>
</addColumn>
</changeSet>
</databaseChangeLog>
@@ -3882,7 +3882,7 @@ CREATE TABLE IF NOT EXISTS `m_portfolio_command_source` (
`made_on_date` datetime NOT NULL,
`checker_id` BIGINT DEFAULT NULL,
`checked_on_date` datetime DEFAULT NULL,
`processing_result_enum` SMALLINT NOT NULL,
`status` SMALLINT NOT NULL,
`product_id` BIGINT DEFAULT NULL,
`transaction_id` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
@@ -3892,7 +3892,7 @@ CREATE TABLE IF NOT EXISTS `m_portfolio_command_source` (
KEY `entity_name` (`entity_name`,`resource_id`),
KEY `made_on_date` (`made_on_date`),
KEY `checked_on_date` (`checked_on_date`),
KEY `processing_result_enum` (`processing_result_enum`),
KEY `status` (`status`),
KEY `office_id` (`office_id`),
KEY `group_id` (`office_id`),
KEY `client_id` (`office_id`),
@@ -5632,10 +5632,12 @@ INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `en
('portfolio_account_type_enum', 2, 'SAVING', 'EXPENSE', 0),
('portfolio_account_type_enum', 3, 'PROVISIONING', 'PROVISIONING', 0),
('portfolio_account_type_enum', 4, 'SHARES', 'SHARES', 0),
('processing_result_enum', 0, 'invalid', 'Invalid', 0),
('processing_result_enum', 1, 'processed', 'Processed', 0),
('processing_result_enum', 2, 'awaiting.approval', 'Awaiting Approval', 0),
('processing_result_enum', 3, 'rejected', 'Rejected', 0),
('status', 0, 'invalid', 'Invalid', 0),
('status', 1, 'processed', 'Processed', 0),
('status', 2, 'awaiting.approval', 'Awaiting Approval', 0),
('status', 3, 'rejected', 'Rejected', 0),
('status', 4, 'underProcessing', 'Under Processing', 0),
('status', 5, 'error', 'Error', 0),
('repayment_period_frequency_enum', 0, 'Days', 'Days', 0),
('repayment_period_frequency_enum', 1, 'Weeks', 'Weeks', 0),
('repayment_period_frequency_enum', 2, 'Months', 'Months', 0),
@@ -4054,7 +4054,7 @@ CREATE TABLE IF NOT EXISTS `m_portfolio_command_source` (
`made_on_date` datetime NOT NULL,
`checker_id` BIGINT DEFAULT NULL,
`checked_on_date` datetime DEFAULT NULL,
`processing_result_enum` SMALLINT NOT NULL,
`status` SMALLINT NOT NULL,
`product_id` BIGINT DEFAULT NULL,
`transaction_id` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
@@ -4064,7 +4064,7 @@ CREATE TABLE IF NOT EXISTS `m_portfolio_command_source` (
KEY `entity_name` (`entity_name`,`resource_id`),
KEY `made_on_date` (`made_on_date`),
KEY `checked_on_date` (`checked_on_date`),
KEY `processing_result_enum` (`processing_result_enum`),
KEY `status` (`status`),
KEY `office_id` (`office_id`),
KEY `group_id` (`office_id`),
KEY `client_id` (`office_id`),
@@ -4075,7 +4075,7 @@ CREATE TABLE IF NOT EXISTS `m_portfolio_command_source` (
-- Dumping data for table mifostenant-reference.m_portfolio_command_source: ~72 rows (approximately)
/*!40000 ALTER TABLE `m_portfolio_command_source` DISABLE KEYS */;
INSERT INTO `m_portfolio_command_source` (`id`, `action_name`, `entity_name`, `office_id`, `group_id`, `client_id`, `loan_id`, `savings_account_id`, `api_get_url`, `resource_id`, `subresource_id`, `command_as_json`, `maker_id`, `made_on_date`, `checker_id`, `checked_on_date`, `processing_result_enum`, `product_id`, `transaction_id`) VALUES
INSERT INTO `m_portfolio_command_source` (`id`, `action_name`, `entity_name`, `office_id`, `group_id`, `client_id`, `loan_id`, `savings_account_id`, `api_get_url`, `resource_id`, `subresource_id`, `command_as_json`, `maker_id`, `made_on_date`, `checker_id`, `checked_on_date`, `status`, `product_id`, `transaction_id`) VALUES
(1, 'CREATE', 'STAFF', 1, NULL, NULL, NULL, NULL, '/staff/template', 1, NULL, '{"isLoanOfficer":true,"officeId":1,"firstname":"Aliya","lastname":"A"}', 1, '2014-03-07 19:10:05', NULL, NULL, 1, NULL, NULL),
(2, 'CREATE', 'USER', 1, NULL, NULL, NULL, NULL, '/users/template', 2, NULL, '{"sendPasswordToEmail":true,"officeId":1,"username":"adama","firstname":"Adam","lastname":"A","email":"adama@123.com","roles":["1"]}', 1, '2014-03-07 19:19:31', NULL, NULL, 1, NULL, NULL),
(3, 'CREATE', 'CLIENT', 1, NULL, 1, NULL, NULL, '/clients/template', 1, NULL, '{"officeId":1,"staffId":1,"firstname":"Smith","lastname":"R","active":true,"locale":"en","dateFormat":"dd MMMM yyyy","activationDate":"07 March 2014","submittedOnDate":"01 January 2010","savingsProductId":null}', 1, '2014-03-07 19:23:36', NULL, NULL, 1, NULL, NULL),
@@ -5889,10 +5889,10 @@ INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `en
('portfolio_account_type_enum', 2, 'SAVING', 'EXPENSE', 0),
('portfolio_account_type_enum', 3, 'PROVISIONING', 'PROVISIONING', 0),
('portfolio_account_type_enum', 4, 'SHARES', 'SHARES', 0),
('processing_result_enum', 0, 'invalid', 'Invalid', 0),
('processing_result_enum', 1, 'processed', 'Processed', 0),
('processing_result_enum', 2, 'awaiting.approval', 'Awaiting Approval', 0),
('processing_result_enum', 3, 'rejected', 'Rejected', 0),
('status', 0, 'invalid', 'Invalid', 0),
('status', 1, 'processed', 'Processed', 0),
('status', 2, 'awaiting.approval', 'Awaiting Approval', 0),
('status', 3, 'rejected', 'Rejected', 0),
('repayment_period_frequency_enum', 0, 'Days', 'Days', 0),
('repayment_period_frequency_enum', 1, 'Weeks', 'Weeks', 0),
('repayment_period_frequency_enum', 2, 'Months', 'Months', 0),