Exemplo n.º 1
0
 public PublishRoutingConnector(UnicastSubscriberTable routingTable, EndpointInstances endpointInstances, IDistributionPolicy distributionPolicy, Func <EndpointInstance, string> resolveTransportAddress)
 {
     this.routingTable            = routingTable;
     this.endpointInstances       = endpointInstances;
     this.distributionPolicy      = distributionPolicy;
     this.resolveTransportAddress = resolveTransportAddress;
 }
Exemplo n.º 2
0
        static void UpdateRoutingTable(XmlRoutingFileParser routingFileParser, XmlRoutingFileAccess routingFile, UnicastRoutingTable routingTable, UnicastSubscriberTable subscriberTable, bool nativeSends, bool nativePublishes)
        {
            try
            {
                var endpoints = routingFileParser.Parse(routingFile.Read());

                var commandRoutes = new List <RouteTableEntry>();
                var eventRoutes   = new List <RouteTableEntry>();

                foreach (var endpoint in endpoints)
                {
                    var route = UnicastRoute.CreateFromEndpointName(endpoint.LogicalEndpointName);
                    foreach (var commandType in endpoint.Commands)
                    {
                        if (nativeSends)
                        {
                            log.Warn($"Selected transport uses native command routing. Route for {commandType.FullName} to {endpoint.LogicalEndpointName} configured in {routingFile.FileUri} will be ignored.");
                        }
                        commandRoutes.Add(new RouteTableEntry(commandType, route));
                    }

                    foreach (var eventType in endpoint.Events)
                    {
                        if (nativePublishes)
                        {
                            log.Warn($"Selected transport uses native event routing. Route for {eventType.FullName} to {endpoint.LogicalEndpointName} configured in {routingFile.FileUri} will be ignored.");
                        }
                        eventRoutes.Add(new RouteTableEntry(eventType, route));
                    }
                }

                routingTable.AddOrReplaceRoutes("FileBasedRouting", commandRoutes);
                subscriberTable.AddOrReplaceRoutes("FileBasedRouting", eventRoutes);

                log.Debug($"Updated routing information from {routingFile.FileUri}");
            }
            catch (Exception e)
            {
                log.Error($"Failed to update routing information from {routingFile.FileUri}. The last valid routing configuration will be used instead.", e);
                throw;
            }
        }