public async Task NotifyNodesForProducerConnection(NotifyProducerConnectionDetails obj) { if (obj.ConnectionType == ConnectionType.Connected) { await producerHubService.ConnectProducerFromOtherNode(obj); } else { await producerHubService.DisconnectProducerFromOtherNode(obj); } }
public Task ConnectProducerFromOtherNode(NotifyProducerConnectionDetails notifyProducerConnectionDetails) { _producerHubRepository.AddProducer($"EXTERNAL-{Guid.NewGuid()}", new Model.Producers.Producer() { IsLocal = false, Component = notifyProducerConnectionDetails.Component, Id = notifyProducerConnectionDetails.Id, ProducerName = notifyProducerConnectionDetails.ProducerName, Product = notifyProducerConnectionDetails.Product, Tenant = notifyProducerConnectionDetails.Tenant, Topic = notifyProducerConnectionDetails.Topic }); return(Task.CompletedTask); }
public Task DisconnectProducerFromOtherNode(NotifyProducerConnectionDetails notifyProducerConnectionDetails) { var producerExternalToRemove = _producerHubRepository.GetProducerByProducerName(notifyProducerConnectionDetails.Tenant, notifyProducerConnectionDetails.Product, notifyProducerConnectionDetails.Component, notifyProducerConnectionDetails.Topic, notifyProducerConnectionDetails.ProducerName); if (producerExternalToRemove.Value != null) { if (producerExternalToRemove.Key.StartsWith("EXTERNAL")) { _producerHubRepository.RemoveProducer(producerExternalToRemove.Key); } } return(Task.CompletedTask); }