-- This contains how to add retry option for integration process (ex:File Data Read Integration Process)

INSERT INTO `ohrm_external_async_event_queue` (`name`, `description`, `enabled`, `is_delayed`) VALUES
('Queue_For_File_Data_Read_Retry','This queue is for file data read retry messages',1,1);

INSERT INTO `ohrm_external_async_event_tag`(`name`, `description`, `enabled`) VALUES
('file_data_read_retry','This tag is for detect file data read failures',1);

SET @file_data_read_queue_id = (SELECT `id` FROM `ohrm_external_async_event_queue` WHERE `name`='Queue_For_File_Data_Read_Retry');
SET @file_data_read_tag_id = (SELECT `id` FROM `ohrm_external_async_event_tag` WHERE `name`='file_data_read_retry');

INSERT INTO `ohrm_external_async_event_tag_queue`(`queue_id`, `tag_id`) VALUES
(@file_data_read_queue_id,@file_data_read_tag_id);

INSERT INTO `ohrm_external_data_queue_consumer`(`name`, `description`, `consumer_class`, `enabled`, `queue_id`) VALUES
('File Data Read queue consumer','This Consumer detects the file data read retry messages','IntegrationQueueConsumer',1,@file_data_read_queue_id);

INSERT INTO `ohrm_external_integration_process` (`name`, `configuration`, `isConsumer`, `enabled`) VALUES
('FileDataRead','{"replacementParameters":{},"subscribedEvents":[],"retries":[{"retry_delay_minutes":1,"publish_to_retry":false},{"retry_delay_minutes":1,"publish_to_retry":false}],"processFailNotificationEmail":"thdeema@gmail.com","processCoordinator":"BasicIntegrationProcessCoordinator","dataFlow":[{"name":"FileDataReadMediator","properties":{"filePath":"\/var\/www\/html\/OHRMStandalone\/TEST\/trunkesbdemo\/symfony\/plugins\/orangehrmCoreIntegrationPlugin\/myData.json","flag":""}},{"name":"FileDataDispatchMediator","properties":{"filePath":"\/var\/www\/html\/OHRMStandalone\/TEST\/trunkesbdemo\/symfony\/plugins\/orangehrmCoreIntegrationPlugin\/Data.json","flag":""}},{"name":"LogMediator","properties":{"fieldName":"","fieldPath":[],"processStop":false}}]}',0,1);

SET @file_data_read_integration_id = (SELECT `id` FROM `ohrm_external_integration_process` WHERE `name`='FileDataRead');
SET @file_data_read_consumer_id = (SELECT `id` FROM `ohrm_external_data_queue_consumer` WHERE `name`='File Data Read queue consumer');

INSERT INTO `ohrm_integration_process_queue_consumer`(`consumer_id`, `integration_id`) VALUES
(@file_data_read_consumer_id,@file_data_read_integration_id);

-- To check schedule based execution add schedule
INSERT INTO `ohrm_symfony_task` (`name`, `short_description`, `long_description`, `command`, `schedule`, `observer_class`, `prevent_overlap`,`user_interface`,`status`) VALUES
('Execute File Data Read Integration Process','Read external file in local machine','Read external file in local machine','php symfony orangehrm:execute-integration-process --process_name="FileDataRead"',null,'',0,'executableTask',1);