Beispiel #1
0
 public async Task NotifyNodesForProducerConnection(NotifyProducerConnectionDetails obj)
 {
     if (obj.ConnectionType == ConnectionType.Connected)
     {
         await producerHubService.ConnectProducerFromOtherNode(obj);
     }
     else
     {
         await producerHubService.DisconnectProducerFromOtherNode(obj);
     }
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }