From a0dcbe61db14cd0e6afafdca84effd1e969b7791 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 26 Sep 2024 13:03:17 -0600 Subject: [PATCH] Issue 30128 system table clusterwide (#30146) Now the system table updates are cluster wide --------- Co-authored-by: freddyDOTCMS Co-authored-by: Jose Castro Co-authored-by: freddyDOTCMS <147462678+freddyDOTCMS@users.noreply.github.com> --- .../java/com/dotcms/business/SystemTableImpl.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dotCMS/src/main/java/com/dotcms/business/SystemTableImpl.java b/dotCMS/src/main/java/com/dotcms/business/SystemTableImpl.java index 729149fa50b4..963c6b755964 100644 --- a/dotCMS/src/main/java/com/dotcms/business/SystemTableImpl.java +++ b/dotCMS/src/main/java/com/dotcms/business/SystemTableImpl.java @@ -1,5 +1,7 @@ package com.dotcms.business; +import com.dotcms.api.system.event.Payload; +import com.dotcms.api.system.event.SystemEventType; import com.dotcms.rest.api.v1.maintenance.JVMInfoResource; import com.dotmarketing.business.APILocator; import com.dotmarketing.business.FactoryLocator; @@ -79,7 +81,15 @@ public void delete(String key) { Try.run(()-> this.systemTableFactory.delete(key)) .getOrElseThrow((e)-> new DotRuntimeException(e.getMessage(), e)); - Try.run(()->HibernateUtil.addCommitListener(()-> - APILocator.getLocalSystemEventsAPI().asyncNotify(new SystemTableUpdatedKeyEvent(key)))); + Try.run(()->HibernateUtil.addCommitListener(()-> { + + final SystemTableUpdatedKeyEvent systemTableUpdatedKeyEvent = new SystemTableUpdatedKeyEvent(key); + // first notify the local system events + APILocator.getLocalSystemEventsAPI().asyncNotify(systemTableUpdatedKeyEvent); + // then notify the cluster wide events + Try.run(()->APILocator.getSystemEventsAPI() // CLUSTER WIDE + .push(SystemEventType.CLUSTER_WIDE_EVENT, new Payload(systemTableUpdatedKeyEvent))) + .onFailure(e -> Logger.error(SystemTableImpl.class, e.getMessage())); + })); } }