From ca86ad401bdbd826104494d50edab547f3aa56f7 Mon Sep 17 00:00:00 2001 From: saba_zedginidze Date: Fri, 8 Nov 2024 12:58:20 +0400 Subject: [PATCH] [MODINVOSTO-187] Send event only after successful transaction --- .../java/org/folio/service/InvoiceLineStorageService.java | 8 ++++---- .../java/org/folio/service/InvoiceStorageService.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/folio/service/InvoiceLineStorageService.java b/src/main/java/org/folio/service/InvoiceLineStorageService.java index 1dc44bc6..9dd7ce07 100644 --- a/src/main/java/org/folio/service/InvoiceLineStorageService.java +++ b/src/main/java/org/folio/service/InvoiceLineStorageService.java @@ -35,11 +35,11 @@ public void createInvoiceLine(InvoiceLine invoiceLine, Handler invoiceLinesDAO.createInvoiceLine(invoiceLine, conn) - .compose(invoiceLineId -> auditOutboxService.saveInvoiceLineOutboxLog(conn, invoiceLine, InvoiceLineAuditEvent.Action.CREATE, headers)) - .compose(v -> auditOutboxService.processOutboxEventLogs(headers, vertxContext))) + .compose(invoiceLineId -> auditOutboxService.saveInvoiceLineOutboxLog(conn, invoiceLine, InvoiceLineAuditEvent.Action.CREATE, headers))) .onSuccess(s -> { log.info("createInvoiceLine:: Successfully created a new invoiceLine by id: {}", invoiceLine.getId()); asyncResultHandler.handle(buildResponseWithLocation(headers.get(OKAPI_URL), INVOICE_LINES_PREFIX + invoiceLine.getId(), invoiceLine)); + auditOutboxService.processOutboxEventLogs(headers, vertxContext); }) .onFailure(f -> { log.error("Error occurred while creating a new invoiceLine with id: {}", invoiceLine.getId(), f); @@ -55,11 +55,11 @@ public void updateInvoiceLine(String id, InvoiceLine invoiceLine, Map invoiceLinesDAO.updateInvoiceLine(id, invoiceLine, conn) - .compose(invoiceLineId -> auditOutboxService.saveInvoiceLineOutboxLog(conn, invoiceLine, InvoiceLineAuditEvent.Action.EDIT, headers)) - .compose(v -> auditOutboxService.processOutboxEventLogs(headers, vertxContext))) + .compose(invoiceLineId -> auditOutboxService.saveInvoiceLineOutboxLog(conn, invoiceLine, InvoiceLineAuditEvent.Action.EDIT, headers))) .onSuccess(s -> { log.info("updateInvoiceLine:: Successfully updated invoice line with id: {}", id); asyncResultHandler.handle(buildNoContentResponse()); + auditOutboxService.processOutboxEventLogs(headers, vertxContext); }) .onFailure(f -> { log.error("Error occurred while updating invoice line with id: {}", id, f); diff --git a/src/main/java/org/folio/service/InvoiceStorageService.java b/src/main/java/org/folio/service/InvoiceStorageService.java index 7f6a89cf..2c7d2d14 100644 --- a/src/main/java/org/folio/service/InvoiceStorageService.java +++ b/src/main/java/org/folio/service/InvoiceStorageService.java @@ -49,11 +49,11 @@ public void postInvoiceStorageInvoices(Invoice invoice, Handler invoiceDAO.createInvoice(invoice, conn) - .compose(invoiceId -> auditOutboxService.saveInvoiceOutboxLog(conn, invoice, InvoiceAuditEvent.Action.CREATE, headers)) - .compose(v -> auditOutboxService.processOutboxEventLogs(headers, vertxContext))) + .compose(invoiceId -> auditOutboxService.saveInvoiceOutboxLog(conn, invoice, InvoiceAuditEvent.Action.CREATE, headers))) .onSuccess(s -> { log.info("postInvoiceStorageInvoices:: Successfully created a new invoice by id: {}", invoice.getId()); asyncResultHandler.handle(buildResponseWithLocation(headers.get(OKAPI_URL), INVOICE_PREFIX + invoice.getId(), invoice)); + auditOutboxService.processOutboxEventLogs(headers, vertxContext); }) .onFailure(f -> { log.error("Error occurred while creating a new invoice with id: {}", invoice.getId(), f); @@ -69,11 +69,11 @@ public void putInvoiceStorageInvoicesById(String id, Invoice invoice, Map invoiceDAO.updateInvoice(id, invoice, conn) - .compose(invoiceId -> auditOutboxService.saveInvoiceOutboxLog(conn, invoice, InvoiceAuditEvent.Action.EDIT, headers)) - .compose(v -> auditOutboxService.processOutboxEventLogs(headers, vertxContext))) + .compose(invoiceId -> auditOutboxService.saveInvoiceOutboxLog(conn, invoice, InvoiceAuditEvent.Action.EDIT, headers))) .onSuccess(s -> { log.info("putInvoiceStorageInvoicesById:: Successfully updated invoice with id: {}", id); asyncResultHandler.handle(buildNoContentResponse()); + auditOutboxService.processOutboxEventLogs(headers, vertxContext); }) .onFailure(f -> { log.error("Error occurred while updating invoice with id: {}", id, f);