/// <summary> /// The RoutingMode specifies how the route is calculated. /// <para/> /// Parameter representation: /// <para/> /// RoutingMode = Type + [TransportModes] + [TrafficMode] + [Feature] /// <para/> /// https://developer.here.com/documentation/routing/topics/resource-param-type-routing-mode.html /// </summary> /// <param name="routingType"> </param> /// <param name="transportMode"></param> /// <param name="trafficMode"> </param> /// <param name="routeFeatures"></param> public RequestRoutingMode(RoutingType routingType, TransportModeType mode, TrafficModeType?trafficMode = null, params RouteFeature[] routeFeatures) { Type = routingType; Mode = mode; Traffic = trafficMode; Features = routeFeatures; }
public override void Deserialize(System.IO.BinaryReader reader) { base.Deserialize(reader); Type = (RoutingType)reader.ReadInt32(); AddVector = new Vector2(reader.ReadSingle(), reader.ReadSingle()); }
public async Task Should_attach_to_address_with_specified_RoutingType(RoutingType routingType, Symbol routingCapability) { var endpoint = GetUniqueEndpoint(); var consumerAttached = new ManualResetEvent(false); Attach attachFrame = null; var testHandler = new TestHandler(@event => { switch (@event.Id) { case EventId.LinkRemoteOpen when @event.Context is Attach attach: attachFrame = attach; consumerAttached.Set(); break; } }); using var host = CreateOpenedContainerHost(endpoint, testHandler); await using var connection = await CreateConnection(endpoint); await using var consumer = await connection.CreateConsumerAsync("test-consumer", routingType); Assert.True(consumerAttached.WaitOne(Timeout)); Assert.NotNull(attachFrame); Assert.IsType <Source>(attachFrame.Source); Assert.Contains(((Source)attachFrame.Source).Capabilities, routingCapability.Equals); }
public static ConsultResponse Consult(this GlobalMedicalFileConsultationPortTypeClient client, CommonInputType common, RoutingType routing, RetrieveTransactionRequestType detailValue, out ArchivingInfo archivingInfo) { var detail = new BlobType(); detail.Id = "_" + Guid.NewGuid().ToString(); detail.ContentType = "text/xml"; detail.ContentEncoding = "none"; var detailStream = new MemoryStream(); var serializer = new XmlSerializer(typeof(RetrieveTransactionRequestType)); serializer.Serialize(detailStream, detailValue); detail.Value = detailStream.ToArray(); ResponseReturnType super = client.Consult(common, routing, detail); archivingInfo = new ArchivingInfo(); archivingInfo.RequestDetail = detail; archivingInfo.RequestXadesT = null; archivingInfo.ResponseDetail = super.Detail; archivingInfo.ResponseXadesT = super.XadesT; var retVal = new ConsultResponse(); retVal.Common = super.CommonOutput; if (super.Detail.ContentType == "text/xml" && super.Detail.ContentEncoding == "none") { var reader = XmlReader.Create(new MemoryStream(super.Detail.Value)); var deserializer = new XmlSerializer(typeof(RetrieveTransactionResponseType)); if (deserializer.CanDeserialize(reader)) { retVal.DetailValue = deserializer.Deserialize(reader) as RetrieveTransactionResponseType; } } return retVal; }
public void PostReceive(string address, RoutingType routingType, string queue, Message message) { foreach (var receiveObserver in _receiveObservers) { receiveObserver.PostReceive(address, routingType, queue, message); } }
public TimeSpan GetTimeTravel( string pointStart, string pointEnd, RoutingType routing = RoutingType.Fastest, TransportType transport = TransportType.Pedestrian ) { var request = new StringBuilder(HERE_API_ROUTE); request.Append("/routing/7.2/calculateroute.json?"); request.Append($"waypoint0={pointStart}&waypoint1={pointEnd}&"); request.Append($"mode={GetModeWse(routing, transport)}&"); request.Append($"app_id={AppId}&"); request.Append($"app_code={AppCode}"); var answer = SendRequest(request.ToString()); var result = _timeRegex.Match(answer).Groups["time"].Value; TimeSpan timeTravel = new TimeSpan(0, Convert.ToInt32(result), 0); return(timeTravel); }
string GetModeWse(RoutingType routing, TransportType transport) { var routingStr = routing == RoutingType.Fastest ? "fastest" : "shortest"; var transportStr = transport == TransportType.Car ? "car" : "pedestrian"; return($"{routingStr};{transportStr}"); }
public void PostReceive(string address, RoutingType routingType, string queue, Message message) { var elapsed = _metrics.Clock.Nanoseconds - _processingStart.Value; var metricTags = GetMetricTags(address, routingType, queue); _metrics.Measure.Histogram.Update(_messageProcessingTime, metricTags, elapsed); _metrics.Measure.Meter.Mark(_messageProcessingRate, metricTags); }
public List <string> GenerateOrdersForCourier( IEnumerable <string> wayPoints, int countPoint, RoutingType routing = RoutingType.Fastest, TransportType transport = TransportType.Pedestrian ) { var request = GenerateOrdersForCourier(wayPoints, routing, transport); return(request.GetRange(1, countPoint)); }
/// <summary> /// Get current routing value /// </summary> /// <param name="routeData"></param> /// <param name="type">Requested routing type</param> /// <returns>string</returns> public static string Routing(this System.Web.Routing.RouteData routeData, RoutingType type) { try { return(type == RoutingType.Area ? routeData.DataTokens[type.ToString().ToLower()].ToString() : routeData.Values[type.ToString().ToLower()].ToString()); } catch (System.NullReferenceException) { return(string.Empty); } }
public async Task Throws_when_created_with_queue_name_and_routing_type(RoutingType routingType) { var endpoint = GetUniqueEndpoint(); using var host = CreateOpenedContainerHost(endpoint); await using var connection = await CreateConnection(endpoint); await Assert.ThrowsAsync <ArgumentException>(() => connection.CreateConsumerAsync(new ConsumerConfiguration { Address = "a1", Queue = "q1", RoutingType = routingType, })); }
public static ResponseReturnType Consult(this GlobalMedicalFileConsultationPortTypeClient client, CommonInputType common, RoutingType routing, BlobType detail) { SendRequestType request = new SendRequestType(); request.CommonInput = common; request.Routing = routing; request.Detail = detail; //No xades required SendResponseType response = client.consultGlobalMedicalFile(request); if (response.Status.Code != "200") throw new InvalidOperationException(String.Format("eHealth returned the following status: {0}, {1}", response.Status.Code, response.Status.Message[0].Value)); //No xades returned return response.Return; }
public async Task Should_sent_message_using_specified_RoutingType(RoutingType routingType, object routingAnnotation) { var endpoint = GetUniqueEndpoint(); using var host = CreateOpenedContainerHost(endpoint); var messageProcessor = host.CreateMessageProcessor("a1"); await using var connection = await CreateConnection(endpoint); var producer = await connection.CreateProducerAsync("a1", routingType); await producer.SendAsync(new Message("foo")); var receivedMsg = messageProcessor.Dequeue(Timeout); Assert.Equal(routingAnnotation, receivedMsg.MessageAnnotations[SymbolUtils.RoutingType]); }
// TODO finish this or abandon? public RoutingVar(string routingExpression, string respOptions) { // find first varname Regex rx = new Regex("go to ([A-Z][A-Z][A-Z]/|[0-9][0-9][0-9][a-z]*/)*[a-zA-z][a-zA-z](\\d{ 5}|\\d{ 3})"); MatchCollection results; Match m; RoutingType rtype = 0; // start with the destination results = rx.Matches(routingExpression); // if there is no varname in the routing expression, this object's properties are null if (results.Count == 0) { varname = null; responseCodes = null; responseLabels = null; return; } m = results[0]; // isolate the varname destination varname = routingExpression.Substring(m.Index, m.Length + 1); // anything after the varname is stored in the sectionReference member. sectionReference = "<Font Size=8>" + routingExpression.Substring(m.Index + m.Length + 1) + "</Font>"; // get options rtype = GetRoutingType(routingExpression); switch (rtype) { case RoutingType.IfResponse: break; case RoutingType.Otherwise: break; case RoutingType.If: break; case RoutingType.Other: break; } // get labels }
public List <string> GenerateOrdersForCourier( IEnumerable <string> wayPoints, RoutingType routing = RoutingType.Fastest, TransportType transport = TransportType.Pedestrian ) { var points = wayPoints.ToList(); points.Add(points.First()); var request = new StringBuilder(HERE_API_WSE); request.Append("/2/findsequence.json?"); request.Append($"start={wayPoints.First()}&"); for (var i = 1; i < wayPoints.Count() - 1; i++) { request.Append($"destination{i}={wayPoints.ElementAt(i)}&"); } request.Append($"end={wayPoints.Last()}&"); request.Append($"mode={GetModeWse(routing, transport)}&"); request.Append($"app_id={AppId}&"); request.Append($"app_code={AppCode}"); var answer = SendRequest(request.ToString()); var listId = _parseRegex.Matches(answer) .Cast <Match>() .Select(m => m.Value) .ToList(); var result = new List <string>(); foreach (var id in listId) { var obj = JsonConvert.DeserializeObject <Route>(id); result.Add(obj.id); } return(result); }
public static string ConvertRoutingType(RoutingType routingType) { switch (routingType) { case RoutingType.Ldap: return Properties.Resources.ROUTINGTYPE_LDAP; case RoutingType.InternalExternal: return Properties.Resources.ROUTINGTYPE_INTEXT; case RoutingType.LdapToDevice: default: { Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage( "ROUTINGTYPE_UNSUPPORTED", "Workshare.PolicyDesigner.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly(), routingType); Logger.LogError(errorMessage.LogString); throw new ArgumentException(errorMessage.DisplayString); } } }
/// <summary> /// Adds the <see cref="IConsumer"/>. /// </summary> /// <param name="builder">The <see cref="IActiveMqBuilder"/>.</param> /// <param name="address">The address name.</param> /// <param name="routingType">The routing type of the address.</param> /// <param name="consumerOptions">The <see cref="IConsumer"/> configuration.</param> /// <param name="handler">A delegate that will be invoked when messages arrive.</param> /// <returns>The <see cref="IActiveMqBuilder"/> that can be used to configure ActiveMQ Artemis Client.</returns> public static IActiveMqBuilder AddConsumer(this IActiveMqBuilder builder, string address, RoutingType routingType, ConsumerOptions consumerOptions, Func <Message, IConsumer, IServiceProvider, CancellationToken, Task> handler) { for (int i = 0; i < consumerOptions.ConcurrentConsumers; i++) { builder.AddConsumer(new ConsumerConfiguration { Address = address, RoutingType = routingType, Credit = consumerOptions.Credit, FilterExpression = consumerOptions.FilterExpression, NoLocalFilter = consumerOptions.NoLocalFilter }, observable => { observable.Address = address; observable.RoutingType = routingType; }, handler); } return(builder); }
/// <summary> /// Adds an array of fields to the FixMessage. /// </summary> /// <param name="fields">An array of fields.</param> private void AddFieldArray(string[] fields) { // This local is used for repeating groups (see below.) StringCollection groupFields = new StringCollection(); // Add each field after parse the values into a "Tag=Value" pair. foreach (string field in fields) { // The 'Split' method has a bothersome habit of leaving a null entry when a token delimiter ends up a the end // of the string. This will quickly filter out those byproducts of the 'Split'. if (field == string.Empty) { continue; } // Break the field up into the 'Tag' and 'Value' fields, parse them and add them to the hash table. string[] values = field.Split('='); if (values.Length > 1) { try { //tagNumber Tag tag = TagConverter.ConvertFrom(values[0]); string stringValue = values[1]; // Handle repeating group fields here. // Per the FIX spec: // "Fields within repeating data groups must be specified in the order that the fields are // specified in the message definition within the FIX specification document. The NoXXX field, // where XXX is the field being counted, specifies the number of repeating group instances and // must immediately precede the repeating group contents." // Generally: // 1. record the number of repeating group instances for a group when the NoXXX field occurs. // 2. when each field in the group is read, save it in the groupFields array, unless it the last field. // 3. when the last field of the group occurs, add a group entry to the group object. // Order is important (See note from FIX spec above.) groupFields index 0 is the first field of the group, 1 is the second, etc. // The xxxxGroup object (derived from class RepeatingGroup) holds the all of the repeating groups relating to "xxxx". // Each repeating group in xxxxGroup is called an Entry. // The groupFields array is temp space to hold the group fields as they are read from the FIX string. switch (tag) { // IOIQualifiers. // There is only one field (IOIQualifier) in each group, so groupFields is not used. case Tag.NoIOIQualifiers: // This field indicates the start of a set of repeating groups. // But for FIX 4.0, only one IOIQualifier is allowed and this field is not used. // So don't create the group object here, create it when the first qualifier is encountered. // See IOIQualifier below. break; case Tag.IOIQualifier: if (!this.ContainsKey(Tag.IoiQualifierGroup)) { // if there is not yet an IoiQualifierGroup, create the group object to hold the repeating groups. this[Tag.IoiQualifierGroup] = new IoiQualifierGroup(); } // get the group object created previously. IoiQualifierGroup ioiQualifierGroup = (IoiQualifierGroup)this[Tag.IoiQualifierGroup]; // IOIQualifier is the only field in this group, so add the group to the IoiQualifierGroup object. // IOIQualifier is not a string in FixMessage, so it needs to be parsed into its correct type. ioiQualifierGroup.Add((IOIQualifier)FixMessage.Parse(tag, stringValue)); break; // RoutingIDs. (Valid in FIX 4.2 only.) // There are 2 fields in each group here, so save the first one in the groupFields array. // (It could just be saved in a string variable, but the array is more general. A group can have more than 2 fields.) // For example: // The following FIX string describes three repeating groups for Routing (215=3), with the first group having // two fields: RoutingType=3 (216=3), and RoutingID=RTEID1 (217=RTEID1). Similarly for groups 2 and 3. // 215=3|216=3|217=RTEID1|216=3|217=RTEID2|216=3|217=RTEID3| case Tag.NoRoutingIDs: // This field indicates the start of a set of repeating groups. // Create the group object to hold the repeating groups. this[Tag.RoutingGroup] = new RoutingGroup(); break; case Tag.RoutingType: // Save the RoutingType string in the groupFields collection. groupFields.Add(stringValue); break; case Tag.RoutingID: // RoutingID is the last field in this group, so add the group to the RoutingGroup object. if (this.Contains(Tag.RoutingGroup)) { // get the group object created above. RoutingGroup routingGroup = (RoutingGroup)this[Tag.RoutingGroup]; if (groupFields.Count > 0) { // Add the current group fields to the group object. // The first (and in this case only) item in the groupFields array is RoutingType. // RoutingType combined with the RoutingID is a complete group. // RoutingID is a string in FixMessage, so it doesn't need to be parsed. // RoutingType is not a string in FixMessage, so it needs to be parsed into its correct type. RoutingType routingType = (RoutingType)FixMessage.Parse(Tag.RoutingType, groupFields[0]); routingGroup.Add(routingType, stringValue); // once the group has been added, clear out the temp array for the next group. groupFields.Clear(); } } break; // Regular processing of (non-repeating) FIX fields. default: this[tag] = FixMessage.Parse(tag, stringValue); break; } } catch { string SenderComp = this.Contains(Tag.SenderCompID) ? this.SenderCompID : string.Empty; string TargetComp = this.Contains(Tag.TargetCompID) ? this.TargetCompID : string.Empty; FluidTrade.Core.EventLog.Error("MsgSeqNum={0}, SenderCompID={1}, TargetCompID={2}: Can't parse FIX field {3}={4}. Field ignored.", this.MsgSeqNum, SenderComp, TargetComp, values[0], values[1]); } } } }
public static Task <IProducer> CreateProducerAsync(this IConnection connection, string address, RoutingType routingType, CancellationToken cancellationToken = default) { var configuration = new ProducerConfiguration { Address = address, RoutingType = routingType }; return(connection.CreateProducerAsync(configuration, cancellationToken)); }
public RoutingAttribute(string path, RoutingType routing) { Path = path; Routing = routing; }
public Task CreateAddress(string name, RoutingType routingType, CancellationToken cancellationToken) { return(CreateAddress(name, new[] { routingType }, cancellationToken)); }
/// <summary> /// Adds the <see cref="IProducer"/> and configures a binding between the <typeparam name="TProducer" /> and named <see cref="IProducer"/> instance. /// </summary> /// <param name="builder">The <see cref="IActiveMqBuilder"/>.</param> /// <param name="address">The address name.</param> /// <param name="routingType">The routing type of the address.</param> /// <param name="producerOptions">The <see cref="IProducer"/> configuration.</param> /// <param name="producerLifetime">The lifetime with which to register the <typeparam name="TProducer" /> in the container.</param> /// <typeparam name="TProducer">The type of the typed producer. The type specified will be registered in the service collection as /// a transient service by default.</typeparam> /// <returns>The <see cref="IActiveMqBuilder"/> that can be used to configure ActiveMQ Artemis Client.</returns> public static IActiveMqBuilder AddProducer <TProducer>(this IActiveMqBuilder builder, string address, RoutingType routingType, ProducerOptions producerOptions, ServiceLifetime producerLifetime = ServiceLifetime.Transient) where TProducer : class { var producerConfiguration = producerOptions.ToConfiguration(); producerConfiguration.Address = address; producerConfiguration.RoutingType = routingType; return(builder.AddProducer <TProducer>(producerConfiguration, producerLifetime)); }
public static Symbol GetRoutingCapability(this RoutingType routingType) => routingType switch {
public Routing(string FromNumber, string ToNumber, RoutingType Type) { this.Type = Type; this.FromNumber = FromNumber; this.ToNumber = ToNumber; }
public Task DeclareAddressAsync(string name, RoutingType routingType, CancellationToken cancellationToken) { return(DeclareAddressAsync(name, new[] { routingType }, cancellationToken)); }
/// <summary> /// Adds the <see cref="IConsumer"/>. /// </summary> /// <param name="builder">The <see cref="IActiveMqBuilder"/>.</param> /// <param name="address">The address name.</param> /// <param name="routingType">The routing type of the address.</param> /// <param name="queue">The queue name.</param> /// <param name="queueOptions">The queue configuration that will be used when queue declaration is enabled.</param> /// <param name="handler">A delegate that will be invoked when messages arrive.</param> /// <returns>The <see cref="IActiveMqBuilder"/> that can be used to configure ActiveMQ Artemis Client.</returns> public static IActiveMqBuilder AddConsumer(this IActiveMqBuilder builder, string address, RoutingType routingType, string queue, QueueOptions queueOptions, Func <Message, IConsumer, IServiceProvider, CancellationToken, Task> handler) { return(builder.AddConsumer(address, routingType, queue, new ConsumerOptions(), queueOptions, handler)); }
/// <summary> /// Adds the <see cref="IConsumer"/>. /// </summary> /// <param name="builder">The <see cref="IActiveMqBuilder"/>.</param> /// <param name="address">The address name.</param> /// <param name="routingType">The routing type of the address.</param> /// <param name="queue">The queue name.</param> /// <param name="consumerOptions">The <see cref="IConsumer"/> configuration.</param> /// <param name="queueOptions">The queue configuration that will be used when queue declaration is enabled.</param> /// <param name="handler">A delegate that will be invoked when messages arrive.</param> /// <returns>The <see cref="IActiveMqBuilder"/> that can be used to configure ActiveMQ Artemis Client.</returns> public static IActiveMqBuilder AddConsumer(this IActiveMqBuilder builder, string address, RoutingType routingType, string queue, ConsumerOptions consumerOptions, QueueOptions queueOptions, Func <Message, IConsumer, IServiceProvider, CancellationToken, Task> handler) { builder.Services.Configure <ActiveMqOptions>(builder.Name, options => { options.QueueConfigurations.Add(new QueueConfiguration { Address = address, RoutingType = routingType, Name = queue, Exclusive = queueOptions.Exclusive, FilterExpression = queueOptions.FilterExpression, GroupBuckets = queueOptions.GroupBuckets, GroupRebalance = queueOptions.GroupRebalance, MaxConsumers = queueOptions.MaxConsumers, AutoCreateAddress = queueOptions.AutoCreateAddress, PurgeOnNoConsumers = queueOptions.PurgeOnNoConsumers }); if (options.AddressConfigurations.TryGetValue(address, out var routingTypes)) { routingTypes.Add(routingType); } else { options.AddressConfigurations[address] = new HashSet <RoutingType> { routingType }; } }); for (int i = 0; i < consumerOptions.ConcurrentConsumers; i++) { builder.AddConsumer(new ConsumerConfiguration { Address = address, Queue = queue, Credit = consumerOptions.Credit, FilterExpression = consumerOptions.FilterExpression, NoLocalFilter = consumerOptions.NoLocalFilter, }, observable => { observable.Address = address; observable.RoutingType = routingType; observable.Queue = queue; }, handler); } return(builder); }
// Used to add routing list entries. public void Add(RoutingType routingType, string routingId) { base.Add(new Entry(routingType, routingId)); }
public static ConsultResponse Consult(this GlobalMedicalFileConsultationPortTypeClient client, CommonInputType common, RoutingType routing, RetrieveTransactionRequestType detailValue, out ArchivingInfo archivingInfo) { var detail = new BlobType(); detail.Id = "_" + Guid.NewGuid().ToString(); detail.ContentType = "text/xml"; detail.ContentEncoding = "none"; var detailStream = new MemoryStream(); var serializer = new XmlSerializer(typeof(RetrieveTransactionRequestType)); serializer.Serialize(detailStream, detailValue); detail.Value = detailStream.ToArray(); ResponseReturnType super = client.Consult(common, routing, detail); archivingInfo = new ArchivingInfo(); archivingInfo.RequestDetail = detail; archivingInfo.RequestXadesT = null; archivingInfo.ResponseDetail = super.Detail; archivingInfo.ResponseXadesT = super.XadesT; var retVal = new ConsultResponse(); retVal.Common = super.CommonOutput; if (super.Detail.ContentType == "text/xml" && super.Detail.ContentEncoding == "none") { var reader = XmlReader.Create(new MemoryStream(super.Detail.Value)); var deserializer = new XmlSerializer(typeof(RetrieveTransactionResponseType)); if (deserializer.CanDeserialize(reader)) { retVal.DetailValue = deserializer.Deserialize(reader) as RetrieveTransactionResponseType; } } return(retVal); }
public static ResponseReturnType Consult(this GlobalMedicalFileConsultationPortTypeClient client, CommonInputType common, RoutingType routing, BlobType detail) { SendRequestType request = new SendRequestType(); request.CommonInput = common; request.Routing = routing; request.Detail = detail; //No xades required SendResponseType response = client.consultGlobalMedicalFile(request); if (response.Status.Code != "200") { throw new InvalidOperationException(String.Format("eHealth returned the following status: {0}, {1}", response.Status.Code, response.Status.Message[0].Value)); } //No xades returned return(response.Return); }
public Task SendMessage(string address, RoutingType routingType, string text, CancellationToken cancellationToken) { return(_producer.SendAsync(address, routingType, new Message(text), cancellationToken)); }
public static Task <IConsumer> CreateConsumerAsync(this IConnection connection, string address, RoutingType routingType, string queue, CancellationToken cancellationToken = default) { var configuration = new ConsumerConfiguration { Address = address, RoutingType = routingType, Queue = queue, Durable = routingType == RoutingType.Multicast, Shared = routingType == RoutingType.Multicast, }; return(connection.CreateConsumerAsync(configuration, cancellationToken)); }
/// <summary> /// Constructs a routing table based on a channel type and routing type /// </summary> /// <param name="name">The name to be assigned to the routing table</param> /// <param name="channelType">The channel type for which the routing table is being created.</param> /// <param name="routingType">The routing type to use</param> /// <returns>An IRoutingTable object</returns> public static IRoutingTable RoutingTableFactory(string name, ChannelType channelType, RoutingType routingType) { if (!RoutingHelper.SupportedRoutingTypes(channelType).Contains(routingType)) { ArgumentException ex = new ArgumentException("invalid channel type, routing type combination"); Logger.LogError(ex.Message); throw ex; } switch (routingType) { case RoutingType.InternalExternal: return SmtpInternalExternalRoutingTableFactory(name); default: return RoutingTableFactory(name, channelType); } }
public void PostReceive(string address, RoutingType routingType, string queue, Message message) => PostReceiveCalled.TrySetResult(true);
public Entry(RoutingType routingType, string routingId) { this.RoutingType = routingType; this.RoutingId = routingId; }