/// <summary> /// Notify all interested nodes in the immutable grid a site model has changed attributes /// </summary> public void DesignStateChanged(DesignNotificationGridMutability targetGrids, Guid siteModelUid, Guid designUid, ImportedFileType fileType, bool designRemoved = false) { var gridFactory = DIContext.Obtain <ITRexGridFactory>(); var evt = new DesignChangedEvent { SiteModelUid = siteModelUid, DesignUid = designUid, FileType = fileType, DesignRemoved = designRemoved }; //if ((targetGrids & DesignNotificationGridMutability.NotifyImmutable) != 0) // gridFactory.Grid(StorageMutability.Immutable).GetMessaging().SendOrdered(evt, MESSAGE_TOPIC_NAME, _messageSendTimeout); //if ((targetGrids & DesignNotificationGridMutability.NotifyMutable) != 0) // gridFactory.Grid(StorageMutability.Mutable).GetMessaging().SendOrdered(evt, MESSAGE_TOPIC_NAME, _messageSendTimeout); if ((targetGrids & DesignNotificationGridMutability.NotifyImmutable) != 0) { evt.SourceNodeUid = gridFactory.Grid(StorageMutability.Immutable).GetCluster().GetLocalNode().Id; SendInvokeStyleMessage("Immutable", evt); } if ((targetGrids & DesignNotificationGridMutability.NotifyMutable) != 0) { evt.SourceNodeUid = gridFactory.Grid(StorageMutability.Mutable).GetCluster().GetLocalNode().Id; SendInvokeStyleMessage("Mutable", evt); } }
/// <summary> /// Sends the message notification schema using the Ignite compute/invoke pattern as a reliable delivery mechanism /// </summary> private void SendInvokeStyleMessage(string gridName, DesignChangedEvent evt) { var gridFactory = DIContext.Obtain <ITRexGridFactory>(); var compute = gridFactory.Grid(StorageMutability.Immutable)?.GetCluster()?.ForAttribute(_messageRoleAttributeName, "True")?.GetCompute(); if (compute != null) { var responses = compute.Broadcast(_messageSendComputeFunc, evt); if (responses == null || responses.Count == 0) { _log.LogWarning($"Site model change notification responses collection from {gridName} is null or empty"); } else { _log.LogInformation($"Received notification confirmation for {responses.Count} recipients in the {gridName} grid."); if (responses.Any(x => !x.Success)) { _log.LogWarning($"Not all targeted nodes in {gridName} successfully processed message, Failures = {string.Join(',', responses.Where(x => !x.Success).Select(x => x.NodeUid))}"); } } } }