Exemplo n.º 1
0
        private void RequestClusterRoutes()
        {
            if (startTime - DateTime.UtcNow < requestClusterRoutesOnStartWindow)
            {
                try
                {
                    var scaleOutAddress = scaleOutConfigurationProvider.GetScaleOutAddress();
                    foreach (var domain in securityProvider.GetAllowedDomains())
                    {
                        var message = Message.Create(new RequestClusterMessageRoutesMessage
                        {
                            RequestorNodeIdentity = scaleOutAddress.Identity,
                            RequestorUri          = scaleOutAddress.Uri.ToSocketAddress()
                        })
                                      .As <Message>();
                        message.SetDomain(domain);
                        message.As <Message>().SignMessage(securityProvider);

                        autoDiscoverySender.EnqueueMessage(message);

                        logger.Info($"Request to discover cluster routes for Domain [{domain}] sent.");
                    }
                }
                catch (Exception err)
                {
                    logger.Error(err);
                }
            }
        }
Exemplo n.º 2
0
 private void SendDiscoverMessageRouteMessage(MessageRoute messageRoute)
 {
     try
     {
         var scaleOutAddress = scaleOutConfigurationProvider.GetScaleOutAddress();
         var domains         = messageRoute.Receiver.IsMessageHub()
                           ? securityProvider.GetAllowedDomains()
                           : new[] { securityProvider.GetDomain(messageRoute.Message.Identity) };
         foreach (var domain in domains)
         {
             var message = Message.Create(new DiscoverMessageRouteMessage
             {
                 RequestorNodeIdentity = scaleOutAddress.Identity,
                 RequestorUri          = scaleOutAddress.Uri.ToSocketAddress(),
                 ReceiverIdentity      = messageRoute.Receiver.IsMessageHub()
                                                                     ? messageRoute.Receiver.Identity
                                                                     : null,
                 MessageContract = messageRoute.Message != null
                                                                    ? new MessageContract
                 {
                     Version   = messageRoute.Message.Version,
                     Identity  = messageRoute.Message.Identity,
                     Partition = messageRoute.Message.Partition
                 }
                                                                    : null
             })
                           .As <Message>();
             message.SetDomain(domain);
             message.SignMessage(securityProvider);
             autoDiscoverySender.EnqueueMessage(message);
         }
     }
     catch (SecurityException err)
     {
         logger.Error(err);
     }
 }