public bool PublishOutage(Topic topic, OutageMessage outageMessage) { bool success; OutagePublication outagePublication = new OutagePublication(topic, outageMessage); using (PublisherProxy publisherProxy = proxyFactory.CreateProxy <PublisherProxy, IPublisher>(EndpointNames.PublisherEndpoint)) { if (publisherProxy == null) { string errMsg = "Publisher proxy is null"; Logger.LogWarn(errMsg); throw new NullReferenceException(errMsg); } try { publisherProxy.Publish(outagePublication, "OUTAGE_PUBLISHER"); Logger.LogInfo($"Outage service published data from topic: {outagePublication.Topic}"); success = true; } catch (Exception e) { string message = $"OutageModel::PublishActiveOutage => exception on PublisherProxy.Publish()"; Logger.LogError(message, e); success = false; } } return(success); }
public async Task <bool> PublishOutageAsync(Topic topic, OutageMessage outageMessage) { bool success; try { OutagePublication outagePublication = new OutagePublication(topic, outageMessage); var publisherClient = PublisherClient.CreateClient(); await publisherClient.Publish(outagePublication, MicroserviceNames.OmsOutageLifecycleService); Logger.LogInformation($"{baseLogString} PublishOutage => Outage service published data to topic: {outagePublication.Topic}"); success = true; } catch (Exception e) { string message = $"{baseLogString} PublishOutage => exception: {e.Message}"; Logger.LogError(message, e); success = false; } return(success); }