public static async Task SendRoatpUpdatedMessage() { var message = ConstructRoatpUpdatedMessage(); await EndpointInstance.Publish(message).ConfigureAwait(false); System.Console.WriteLine($"Published Roatp Updated event: {message}"); }
public void Two_instances_with_same_properties_are_equal() { var i1 = new EndpointInstance("Endpoint").SetProperty("P1", "V1").SetProperty("P2", "V2"); var i2 = new EndpointInstance("Endpoint").SetProperty("P2", "V2").SetProperty("P1", "V1"); Assert.IsTrue(i1.Equals(i2)); }
static Dictionary <Type, string> BuildNewPublisherMap(EndpointInstance endpointInstance, Type[] publishedTypes, Dictionary <Type, string> publisherMap) { var newPublisherMap = new Dictionary <Type, string>(); var endpointName = endpointInstance.Endpoint; foreach (var pair in publisherMap) { if (pair.Value != endpointName) { newPublisherMap[pair.Key] = pair.Value; } } foreach (var publishedType in publishedTypes) { if (newPublisherMap.ContainsKey(publishedType)) { log.Warn($"More than one endpoint advertises publishing of {publishedType}: {newPublisherMap[publishedType]}, {endpointInstance.Endpoint}"); } else { newPublisherMap[publishedType] = endpointName; } } return(newPublisherMap); }
async Task UpdateCaches(EndpointInstance instanceName, Type[] handledTypes, Type[] publishedTypes) { var newInstanceMap = BuildNewInstanceMap(instanceName); var newEndpointMap = BuildNewEndpointMap(instanceName.Endpoint, handledTypes, endpointMap); var newPublisherMap = BuildNewPublisherMap(instanceName, publishedTypes, publisherMap); LogChangesToEndpointMap(endpointMap, newEndpointMap); LogChangesToInstanceMap(instanceMap, newInstanceMap); var toSubscribe = LogChangesToPublisherMap(publisherMap, newPublisherMap).ToArray(); #region AddOrReplace routingTable.AddOrReplaceRoutes("AutomaticRouting", newEndpointMap.Select( x => new RouteTableEntry(x.Key, UnicastRoute.CreateFromEndpointName(x.Value))).ToList()); publishers.AddOrReplacePublishers("AutomaticRouting", newPublisherMap.Select( x => new PublisherTableEntry(x.Key, PublisherAddress.CreateFromEndpointName(x.Value))).ToList()); endpointInstances.AddOrReplaceInstances("AutomaticRouting", newInstanceMap.SelectMany(x => x.Value).ToList()); #endregion instanceMap = newInstanceMap; endpointMap = newEndpointMap; publisherMap = newPublisherMap; foreach (var type in toSubscribe.Intersect(messageTypesHandledByThisEndpoint)) { await messageSession.Subscribe(type) .ConfigureAwait(false); } }
/// <summary> /// Creates a destination based on the name of the endpoint instance. /// </summary> /// <param name="instance">Destination instance name.</param> /// <returns>The new destination route.</returns> public static UnicastRoute CreateFromEndpointInstance(EndpointInstance instance) { Guard.AgainstNull(nameof(instance), instance); return(new UnicastRoute { Instance = instance }); }
/// <summary> /// Creates a destination based on the name of the endpoint instance. /// </summary> /// <param name="instance">Destination instance name.</param> /// <returns>The new destination route.</returns> public static UnicastRoute CreateFromEndpointInstance(EndpointInstance instance) { Guard.AgainstNull(nameof(instance), instance); return new UnicastRoute { Instance = instance }; }
void SpecialCaseTransportAddress(EndpointConfiguration endpointConfiguration) { #region Routing-SpecialCaseTransportAddress EndpointInstance endpointInstance = new EndpointInstance("Sales", "1"); var transport = endpointConfiguration.UseTransport <MyTransport>(); transport.AddAddressTranslationException(endpointInstance, "Sales-One@MachineA"); #endregion }
public async Task OnRemoved(Entry entry) { var deserializedData = JsonConvert.DeserializeObject <RoutingInfo>(entry.Data); var instanceName = new EndpointInstance(deserializedData.EndpointName, deserializedData.Discriminator, deserializedData.InstanceProperties); log.Info($"Instance {instanceName} removed from routing tables."); await UpdateCaches(instanceName, new Type[0], new Type[0]) .ConfigureAwait(false); }
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance) { var schemaSettings = settings.Get <EndpointSchemasSettings>(); string schema; if (schemaSettings.TryGet(instance.Endpoint, out schema) == false) { schema = addressParser.DefaultSchema; } return(instance.SetProperty(SettingsKeys.SchemaPropertyKey, schema)); }
/// <summary> /// <see cref="TransportInfrastructure.BindToLocalEndpoint" /> /// </summary> public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance) { var schemaSettings = settings.Get <EndpointSchemaAndCatalogSettings>(); string schema; if (schemaSettings.TryGet(instance.Endpoint, out schema) == false) { schema = addressTranslator.DefaultSchema; } var result = instance.SetProperty(SettingsKeys.SchemaPropertyKey, schema); return(result); }
public Task OnChanged(Entry entry) { var deserializedData = JsonConvert.DeserializeObject <RoutingInfo>(entry.Data); var instanceName = new EndpointInstance(deserializedData.EndpointName, deserializedData.Discriminator, deserializedData.InstanceProperties); var handledTypes = deserializedData.HandledMessageTypes.Select(x => Type.GetType(x, false)) .Where(x => x != null) .ToArray(); var publishedTypes = deserializedData.PublishedMessageTypes.Select(x => Type.GetType(x, false)) .Where(x => x != null) .ToArray(); return(UpdateCaches(instanceName, handledTypes, publishedTypes)); }
Dictionary <string, HashSet <EndpointInstance> > BuildNewInstanceMap(EndpointInstance instanceName) { var newInstanceMap = new Dictionary <string, HashSet <EndpointInstance> >(); foreach (var pair in instanceMap) { var otherInstances = pair.Value.Where(x => x != instanceName); newInstanceMap[pair.Key] = new HashSet <EndpointInstance>(otherInstances); } var endpointName = instanceName.Endpoint; if (!newInstanceMap.TryGetValue(endpointName, out var endpointEntry)) { endpointEntry = new HashSet <EndpointInstance>(); newInstanceMap[endpointName] = endpointEntry; } endpointEntry.Add(instanceName); return(newInstanceMap); }
public Task OnChanged(Entry entry) { var deserializedData = JsonConvert.DeserializeObject <RoutingInfo>(entry.Data); var instanceName = new EndpointInstance(deserializedData.EndpointName, deserializedData.Discriminator, deserializedData.InstanceProperties); var handledTypes = deserializedData.HandledMessageTypes.Select(x => Type.GetType(x, false)) .Where(x => x != null) .ToArray(); var publishedTypes = deserializedData.PublishedMessageTypes.Select(x => Type.GetType(x, false)) .Where(x => x != null) .ToArray(); EndpointInstanceInfo instanceInfo; if (!instanceInformation.TryGetValue(instanceName, out instanceInfo)) { var newInstanceInformation = new Dictionary <EndpointInstance, EndpointInstanceInfo>(instanceInformation); instanceInfo = new EndpointInstanceInfo(); newInstanceInformation[instanceName] = instanceInfo; instanceInformation = newInstanceInformation; } if (deserializedData.Active) { instanceInfo.Activate(deserializedData.Timestamp); log.Debug($"Instance {instanceName} active (heartbeat)."); } else { instanceInfo.Deactivate(); log.Info($"Instance {instanceName} deactivated."); } return(UpdateCaches(instanceName, handledTypes, publishedTypes)); }
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance) => instance;
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance) { return(new EndpointInstance(individualization.Individualize(instance.Endpoint), instance.Discriminator, instance.Properties)); }
/// <summary> /// Returns an endpoint instance bound to a given machine name. /// </summary> /// <param name="instance">A plain instance.</param> /// <param name="machineName">Machine name.</param> public static EndpointInstance AtMachine(this EndpointInstance instance, string machineName) { Guard.AgainstNull(nameof(instance), instance); Guard.AgainstNullAndEmpty(nameof(machineName), machineName); return(instance.SetProperty("machine", machineName)); }
/// <summary> /// Creates a logical address for a remote endpoint. /// </summary> /// <param name="endpointInstance">The endpoint instance that describes the remote endpoint.</param> public static LogicalAddress CreateRemoteAddress(EndpointInstance endpointInstance) { return(new LogicalAddress(endpointInstance, null)); }
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance) { throw new NotImplementedException(); }
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance) { return(new EndpointInstance(instance.Endpoint)); }
/// <summary> /// Creates a logical address for a remote endpoint. /// </summary> /// <param name="endpointInstance">The endpoint instance that describes the remote endpoint.</param> public static LogicalAddress CreateRemoteAddress(EndpointInstance endpointInstance) { return new LogicalAddress(endpointInstance, null); }
public SpecificInstanceDistributionStrategy(EndpointInstance instance, Func<EndpointInstance, string> transportAddressTranslation, DistributionStrategyScope scope) : base(instance.Endpoint, scope) { this.instance = instance; this.transportAddressTranslation = transportAddressTranslation; }
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance, ReadOnlySettings settings) { return(instance); }
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance) => instance.AtMachine(RuntimeEnvironment.MachineName);
/// <summary> /// Returns the discriminator for this endpoint instance. /// </summary> public abstract EndpointInstance BindToLocalEndpoint(EndpointInstance instance);
public SpecificInstanceDistributionStrategy(EndpointInstance instance, Func <EndpointInstance, string> transportAddressTranslation, DistributionStrategyScope scope) : base(instance.Endpoint, scope) { this.instance = instance; this.transportAddressTranslation = transportAddressTranslation; }
LogicalAddress(EndpointInstance endpointInstance, string qualifier) { EndpointInstance = endpointInstance; Qualifier = qualifier; }
void SpecialCaseTransportAddress(EndpointConfiguration endpointConfiguration) { #region Routing-SpecialCaseTransportAddress EndpointInstance endpointInstance = new EndpointInstance("Sales", "1"); endpointConfiguration .UseTransport<MyTransport>() .AddAddressTranslationException(endpointInstance, "Sales-One@MachineA"); #endregion }
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance) { return(topology.BindToLocalEndpoint(instance)); }
public EndpointInstance BindToLocalEndpoint(EndpointInstance endpointInstance) { return(transportInfrastructure.BindToLocalEndpoint(endpointInstance)); }
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance) { return(instance); }
string CustomTranslationRule(EndpointInstance endpointInstanceName) { throw new NotImplementedException(); }
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance) { return(baseTransportInfrastructure.BindToLocalEndpoint(instance)); }
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance) { return instance; }
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance, ReadOnlySettings settings) { throw new NotImplementedException(); }
public EndpointInstance BindToLocalEndpoint(EndpointInstance instance) { var individualization = container.Resolve <IIndividualizationStrategy>(); return(new EndpointInstance(individualization.Individualize(instance.Endpoint), instance.Discriminator, instance.Properties)); }
public override EndpointInstance BindToLocalEndpoint(EndpointInstance instance, ReadOnlySettings settings) { return instance; }