private static TriggerEventType ConvertChannel(TriggerChannel channel) { switch (channel) { case TriggerChannel.Email: return(TriggerEventType.Email); case TriggerChannel.SMS: return(TriggerEventType.Sms); case TriggerChannel.LiveData: return(TriggerEventType.LiveData); case TriggerChannel.MQTT: return(TriggerEventType.Mqtt); case TriggerChannel.HttpPost: return(TriggerEventType.HttpPost); case TriggerChannel.HttpGet: return(TriggerEventType.HttpGet); case TriggerChannel.ControlMessage: return(TriggerEventType.ControlMessage); default: throw new ArgumentOutOfRangeException(nameof(channel), channel, null); } }
protected virtual ITriggerChannel CreateTriggerChannel(string triggerName, string objectName, TriggerEventType eventType) { AssertAuthenticated(); lock (triggerLock) { if (triggerChannels == null) { triggerChannels = new Dictionary <int, TriggerChannel>(); } foreach (TriggerChannel channel in triggerChannels.Values) { // If there's an open channel for the trigger return it if (channel.ShouldNotify(triggerName, objectName, eventType)) { return(channel); } } int id = ++triggerId; var newChannel = new TriggerChannel(this, id, triggerName, objectName, eventType); triggerChannels[id] = newChannel; return(newChannel); } }
private void TestTriggerChannel(TriggerChannel channel, string[] urls, bool isSensor, ChannelItem channelItem = null) { var countOverride = new Dictionary <Content, int> { [Content.Sensors] = isSensor ? 2 : 0 }; var itemOverride = channelItem != null ? new Dictionary <Content, BaseItem[]> { [Content.Channels] = new[] { channelItem } } : null; var parameters = new ThresholdTriggerParameters(1001) { Channel = channel }; Execute( c => c.AddNotificationTrigger(parameters, false), urls, countOverride, itemOverride ); }
/// <summary> /// Initializes a new instance of the <see cref="ThresholdTriggerParameters"/> class for creating a new trigger from an existing <see cref="TriggerType.Threshold"/> <see cref="NotificationTrigger"/>. /// </summary> /// <param name="objectId">The object ID the trigger will apply to.</param> /// <param name="sourceTrigger">The notification trigger whose properties should be used.</param> public ThresholdTriggerParameters(int objectId, NotificationTrigger sourceTrigger) : base(TriggerType.Threshold, objectId, sourceTrigger, ModifyAction.Add) { OffNotificationAction = sourceTrigger.OffNotificationAction; Latency = sourceTrigger.Latency; Threshold = sourceTrigger.ThresholdInternal; Condition = sourceTrigger.Condition; Channel = sourceTrigger.Channel; }
/// <summary> /// Initializes a new instance of the <see cref="ThresholdTriggerParameters"/> class for creating a new notification trigger. /// </summary> /// <param name="objectId">The object ID the trigger will apply to.</param> public ThresholdTriggerParameters(int objectId) : base(TriggerType.Threshold, objectId, (int?)null, ModifyAction.Add) { OffNotificationAction = null; Channel = TriggerChannel.Primary; Condition = TriggerCondition.Above; Threshold = 0; Latency = 60; }
/// <summary> /// Initializes a new instance of the <see cref="ThresholdTriggerParameters"/> class for creating a new trigger from an existing <see cref="TriggerType.Threshold"/> <see cref="NotificationTrigger"/>. /// </summary> /// <param name="objectOrId">The object or object ID the trigger will apply to.</param> /// <param name="sourceTrigger">The notification trigger whose properties should be used.</param> public ThresholdTriggerParameters(Either <IPrtgObject, int> objectOrId, NotificationTrigger sourceTrigger) : base(TriggerType.Threshold, objectOrId, sourceTrigger, ModifyAction.Add) { OffNotificationAction = sourceTrigger.OffNotificationAction; Latency = sourceTrigger.Latency; Threshold = sourceTrigger.Threshold; Condition = sourceTrigger.Condition; Channel = sourceTrigger.Channel; }
/// <summary> /// Binds the intermediaries and endpoint together. /// </summary> /// <param name="channelKeyPrefix">The prefix for the channel key.</param> /// <param name="targetApplication">The application in the target.</param> /// <param name="sendPort">The send port.</param> /// <param name="route">The chain of messaging objects that need to be bound by channels.</param> private void BindResponseChannels(string channelKeyPrefix, Application targetApplication, SendPort sendPort, IList <MessagingObject> route) { _logger.LogDebug(TraceMessages.BindingChannelsForReceivePort, RuleName, sendPort.Name); // Assume route is in order, that is, first entry is the start of the route. As the route is built // in this class, not expecting anything other than intermediaries and optionally an endpoint. for (var i = 0; i < route.Count - 1; i++) { // Determine from and to steps var fromStep = route[i]; var toStep = route[i + 1]; // Create channel var channel = new TriggerChannel(MigrationTargetResources.TriggerChannelName) { Description = string.Format(CultureInfo.CurrentCulture, MigrationTargetResources.TriggerChannelDescription, toStep), Key = $"{channelKeyPrefix}:{ModelConstants.TriggerChannelLeafKey}Response:{fromStep.Name.FormatKey()}-{toStep.Name.FormatKey()}", Rating = ConversionRating.FullConversion }; // Are we going from a routing slip router? if (fromStep is RoutingSlipRouter) { // Set URL var scenarioStep = toStep.Properties[ModelConstants.ScenarioStepName]; channel.TriggerUrl = $"/routingManager/route/{scenarioStep}"; // Label the channel appropriately channel.Properties.Add(ModelConstants.RouteLabel, MigrationTargetResources.RouteToChannelLabel); } else { // Label the channel appropriately channel.Properties.Add(ModelConstants.RouteLabel, MigrationTargetResources.RouteFromChannelLabel); } // Add channel to application targetApplication.Channels.Add(channel); // Bind channel with endpoint and intermediaries if (fromStep is Endpoint endpoint) { endpoint.OutputChannelKeyRef = channel.Key; } if (fromStep is Intermediary intermediary) { intermediary.OutputChannelKeyRefs.Add(channel.Key); } ((Intermediary)toStep).InputChannelKeyRefs.Add(channel.Key); } }
private void TestTriggerChannel(int objectId, TriggerChannel channel, Func <object, object, string, bool> validator = null) { var parameters = new ThresholdTriggerParameters(objectId) { Channel = channel }; DoubleAddRemoveTrigger( parameters, t => new ThresholdTriggerParameters(objectId, t), validator ); }
private void UpdateChannel(TriggerParameter parameter, Lazy <PrtgObject> @object) { var str = parameter.Value?.ToString(); if (@object.Value.Type == ObjectType.Sensor && !string.IsNullOrWhiteSpace(str)) { UpdateChannelFromChannel(parameter, @object, str); } else { parameter.Value = TriggerChannel.Parse(parameter.Value); } }
public async Task RemoveActionAsync(Trigger trigger, TriggerChannel channel, CancellationToken ct = default) { using var builder = StoredProcedureBuilder.Create(this.m_ctx.Connection); builder.WithParameter("triggerid", trigger.ID, NpgsqlDbType.Bigint); builder.WithParameter("channel", (int)channel, NpgsqlDbType.Integer); builder.WithFunction(NetworkApi_DeleteTriggerAction); await using var reader = await builder.ExecuteAsync(ct).ConfigureAwait(false); var result = await reader.ReadAsync(ct).ConfigureAwait(false); if (!result) { throw new ArgumentException("Unable to remove non-existing trigger action."); } }
private void UpdateChannel(TriggerParameter parameter, Lazy <PrtgObject> @object) { var str = parameter.Value?.ToString(); if (@object.Value.Type == ObjectType.Sensor && !string.IsNullOrWhiteSpace(str)) { UpdateChannelFromChannel(parameter, @object, str); } else { if (str == null) { throw new ArgumentNullException($"Cannot specify 'null' for parameter '{parameter.Property}'. Value must non-null and convertable to one of {typeof(StandardTriggerChannel).FullName}, {typeof(Channel).FullName} or {typeof(int).FullName}.", (Exception)null); } parameter.Value = TriggerChannel.Parse(parameter.Value); } }
private IEnumerable <NotificationTrigger> FilterResponseRecordsByChannel(object[] channel, Func <NotificationTrigger, object> func, IEnumerable <NotificationTrigger> triggers) { foreach (var trigger in triggers) { if (trigger.Channel != null) { foreach (var obj in channel) { TriggerChannel result; if (TriggerChannel.TryParse(obj, out result) && trigger.Channel.Equals(result)) { yield return(trigger); break; } else { if (Object == null) { Object = client.GetObject(ObjectId, true) as SensorOrDeviceOrGroupOrProbe; } if (Object is Sensor) { var channels = client.GetChannels(Object.Id); var wildcard = new WildcardPattern(obj?.ToString(), WildcardOptions.IgnoreCase); var match = channels.Any(c => wildcard.IsMatch(trigger.Channel.ToString())); if (match) { yield return(trigger); break; } } } } } } }
private void TriggerParameters_Edit_CanSetUnsetValue(TriggerParameters parameters) { var properties = PrtgAPIHelpers.GetNormalProperties(parameters.GetType()); foreach (var prop in properties) { prop.SetValue(parameters, null); if (prop.Name == nameof(TriggerProperty.OnNotificationAction) || prop.Name == nameof(TriggerProperty.OffNotificationAction) || prop.Name == nameof(TriggerProperty.EscalationNotificationAction)) { Assert.IsTrue(prop.GetValue(parameters).ToString() == TriggerParameters.EmptyNotificationAction().ToString(), $"Property '{prop.Name}' was not empty."); } else { Assert.IsTrue(prop.GetValue(parameters) == null, $"Property '{prop.Name}' was not null."); } object defaultValue = null; if (prop.PropertyType.Name == nameof(TriggerChannel)) { defaultValue = new TriggerChannel(1234); } else if (prop.Name == nameof(VolumeTriggerParameters.UnitSize)) { if (parameters is VolumeTriggerParameters) { defaultValue = TestReflectionUtilities.GetDefaultUnderlying(typeof(DataVolumeUnit)).ToString().ToEnum <DataUnit>(); } else { defaultValue = TestReflectionUtilities.GetDefaultUnderlying(prop.PropertyType); } } else { defaultValue = TestReflectionUtilities.GetDefaultUnderlying(prop.PropertyType); } prop.SetValue(parameters, defaultValue); Assert.IsTrue(prop.GetValue(parameters) != null, $"Property '{prop.Name}' was null."); } }
private void TestTriggerChannel(TriggerChannel channel, string[] urls, bool isSensor, ChannelItem channelItem = null) { var client = Initialize_Client(new AddressValidatorResponse(urls) { CountOverride = new Dictionary <Content, int> { [Content.Sensors] = isSensor ? 2 : 0 }, ItemOverride = channelItem != null ? new Dictionary <Content, BaseItem[]> { [Content.Channels] = new[] { channelItem } } : null }); var parameters = new ThresholdTriggerParameters(1001) { Channel = channel }; client.AddNotificationTrigger(parameters, false); }
internal static TriggerChannel GetTriggerChannel(TriggerParameters parameters) { TriggerChannel channel = null; switch (parameters.Type) { case TriggerType.Speed: channel = ((SpeedTriggerParameters)parameters).Channel; break; case TriggerType.Volume: channel = ((VolumeTriggerParameters)parameters).Channel; break; case TriggerType.Threshold: channel = ((ThresholdTriggerParameters)parameters).Channel; break; } return(channel); }
protected virtual ITriggerChannel CreateTriggerChannel(string triggerName, string objectName, TriggerEventType eventType) { AssertAuthenticated(); lock (triggerLock) { if (triggerChannels == null) triggerChannels = new Dictionary<int, TriggerChannel>(); foreach (TriggerChannel channel in triggerChannels.Values) { // If there's an open channel for the trigger return it if (channel.ShouldNotify(triggerName, objectName, eventType)) return channel; } int id = ++triggerId; var newChannel = new TriggerChannel(this, id, triggerName, objectName, eventType); triggerChannels[id] = newChannel; return newChannel; } }
public static object GetTriggerChannelSource(TriggerChannel channel) => channel.channel;
/// <summary> /// Builds a target model. /// </summary> /// <param name="model">The model.</param> private static void BuildTargetModel(AzureIntegrationServicesModel model) { model.MigrationTarget.TargetEnvironment = AzureIntegrationServicesTargetEnvironment.Consumption; model.MigrationTarget.DeploymentEnvironment = "dev"; model.MigrationTarget.AzurePrimaryRegion = "UK South"; model.MigrationTarget.AzureSecondaryRegion = "West US"; model.MigrationTarget.UniqueDeploymentId = "unit-test"; model.MigrationTarget.MessageBus = new MessageBus() { Name = "Message Bus", Key = "MessageBus", Type = MessagingObjectType.MessageBus, Description = "Azure Integration Services Message Bus", ResourceMapKey = "messageBus", Rating = ConversionRating.NotSupported }; // Message Bus resources var resource1 = new TargetResourceTemplate() { TemplateKey = "deployResources", TemplateType = "microsoft.template.powershell", ResourceName = "deploy-resources", ResourceType = "microsoft.scripts.powershell", OutputPath = "" }; resource1.ResourceTemplateFiles.Add("Deploy-All.ps1.liquid"); resource1.ResourceTemplateFiles.Add("TearDown-All.ps1.liquid"); model.MigrationTarget.MessageBus.Resources.Add(resource1); var resource2 = new TargetResourceTemplate() { TemplateKey = "messageBusAzureResourceGroup", TemplateType = "microsoft.template.arm", ResourceName = "arrg-aimmsgbus-dev-uksouth", ResourceType = "microsoft.groups.azureresourcegroup", OutputPath = "messagebus/messagebusgroup", }; resource2.Tags.Add("ApplicationName", "AIM-MessageBus"); resource2.Tags.Add("Env", "dev"); resource2.Parameters.Add("azure_primary_region", "UK South"); resource2.Parameters.Add("azure_secondary_region", "West US"); resource2.Parameters.Add("azure_subscription_id", ""); resource2.ResourceTemplateFiles.Add("messagebus/messagebusgroup/messagebusgroup.dev.parameters.json.liquid"); resource2.ResourceTemplateFiles.Add("messagebus/messagebusgroup/messagebusgroup.json.liquid"); model.MigrationTarget.MessageBus.Resources.Add(resource2); var resource3 = new TargetResourceTemplate() { TemplateKey = "deployMessageBusGroup", TemplateType = "microsoft.template.powershell", ResourceName = "arrg-aimmsgbus-dev-uksouth", ResourceType = "microsoft.scripts.powershell", OutputPath = "messagebus/messagebusgroup", }; resource3.Parameters.Add("azure_primary_region", "UK South"); resource3.Parameters.Add("azure_secondary_region", "West US"); resource3.Parameters.Add("azure_subscription_id", ""); resource3.ResourceTemplateFiles.Add("messagebus/messagebusgroup/Deploy-10-MessageBusGroup.ps1.liquid"); resource3.ResourceTemplateFiles.Add("messagebus/messagebusgroup/New-MessageBusGroup.ps1.liquid"); resource3.ResourceTemplateFiles.Add("messagebus/messagebusgroup/TearDown-10-MessageBusGroup.ps1.liquid"); resource3.ResourceTemplateFiles.Add("messagebus/messagebusgroup/Remove-MessageBusGroup.ps1.liquid"); model.MigrationTarget.MessageBus.Resources.Add(resource3); var resource4 = new TargetResourceTemplate() { TemplateKey = "messageBusServiceAzureRole", TemplateType = "microsoft.template.json", ResourceName = "arapim-aimmsgbussvc-dev", ResourceType = "microsoft.security.azurerole", OutputPath = "messagebus/messagebusservice" }; resource4.ResourceTemplateFiles.Add("messagebus/messagebusservice/messagebusservice.logicappsrole.json"); model.MigrationTarget.MessageBus.Resources.Add(resource4); // Applications var application1 = new Application() { Name = "BTS2010FlatFilePipelineSample", Key = "MessageBus:BTS2010FlatFilePipelineSample", Type = MessagingObjectType.Application, Description = "Azure Integration Application", ResourceMapKey = "applicationBTS2010FlatFilePipelineSample", Rating = ConversionRating.NoRating, }; model.MigrationTarget.MessageBus.Applications.Add(application1); var appresource1 = new TargetResourceTemplate() { TemplateKey = "applicationAzureResourceGroupBTS2010FlatFilePipelineSample", TemplateType = "microsoft.template.arm", ResourceName = "arrg-aimapp-bts2010flatfilepipelinesample-dev-uksouth", ResourceType = "microsoft.groups.azureresourcegroup", OutputPath = "applications/bts2010flatfilepipelinesample/bts2010flatfilepipelinesamplegroup", }; appresource1.Tags.Add("ApplicationName", "BTS2010FlatFilePipelineSample"); appresource1.Tags.Add("Env", "dev"); appresource1.Parameters.Add("azure_primary_region", "UK South"); appresource1.Parameters.Add("azure_secondary_region", "West US"); appresource1.Parameters.Add("azure_subscription_id", ""); appresource1.ResourceTemplateFiles.Add("application/applicationgroup/applicationgroup.json.liquid"); appresource1.ResourceTemplateFiles.Add("application/applicationgroup/applicationgroup.dev.parameters.json.liquid"); application1.Resources.Add(appresource1); var appresource2 = new TargetResourceTemplate() { TemplateKey = "deployApplicationGroupBTS2010FlatFilePipelineSample", TemplateType = "microsoft.template.powershell", ResourceName = "arrg-aimapp-bts2010flatfilepipelinesample-dev-uksouth", ResourceType = "microsoft.scripts.powershell", OutputPath = "applications/bts2010flatfilepipelinesample/bts2010flatfilepipelinesamplegroup", }; appresource2.Parameters.Add("azure_primary_region", "UK South"); appresource2.Parameters.Add("azure_secondary_region", "West US"); appresource2.Parameters.Add("azure_subscription_id", ""); appresource2.ResourceTemplateFiles.Add("application/applicationgroup/Deploy-10-ApplicationGroup.ps1.liquid"); appresource2.ResourceTemplateFiles.Add("application/applicationgroup/New-ApplicationGroup.ps1.liquid"); appresource2.ResourceTemplateFiles.Add("application/applicationgroup/TearDown-10-ApplicationGroup.ps1.liquid"); appresource2.ResourceTemplateFiles.Add("application/applicationgroup/Remove-ApplicationGroup.ps1.liquid"); application1.Resources.Add(appresource2); // Messages in the application var documentmessage1 = new DocumentMessage() { MessageType = MessageType.Document, ContentType = MessageContentType.Xml, MessageSchema = new MessageSchema() { Name = "NewOrder", ResourceKeyRef = "BTS2010FlatFilePipelineSample:ITEM~0:BTS2010FlatFilePipelineSample:NewOrder:schema:Order" }, Name = "NewOrder", Key = "MessageBus:BTS2010FlatFilePipelineSample:NewOrder", Type = MessagingObjectType.Message, Description = "Azure Integration Application Schema", ResourceMapKey = "applicationMessageBTS2010FlatFilePipelineSampleNewOrder", Rating = ConversionRating.NoRating }; application1.Messages.Add(documentmessage1); var messageresource1 = new TargetResourceTemplate() { TemplateKey = "deploySchemaBTS2010FlatFilePipelineSampleNewOrder", TemplateType = "microsoft.template.powershell", ResourceName = "NewOrder", ResourceType = "microsoft.scripts.powershell", OutputPath = "applications/BTS2010FlatFilePipelineSample/messages/neworder", }; messageresource1.Parameters.Add("azure_primary_region", "UK South"); messageresource1.Parameters.Add("azure_secondary_region", "West US"); messageresource1.Parameters.Add("azure_subscription_id", ""); messageresource1.Parameters.Add("azure_resource_group_name", "arrg-aimmsgbus-dev-uksouth"); messageresource1.Parameters.Add("azure_integration_account_name", "arintacc-aimartifactstore-dev-uksouth"); messageresource1.Parameters.Add("azure_message_schema_name", "BTS2010FlatFilePipelineSample.NewOrder"); messageresource1.ResourceTemplateFiles.Add("messages/schemas/Deploy-100-Schema.ps1.liquid"); messageresource1.ResourceTemplateFiles.Add("messages/schemas/New-Schema.ps1.liquid"); messageresource1.ResourceTemplateFiles.Add("messages/schemas/Remove-Schema.ps1.liquid"); messageresource1.ResourceTemplateFiles.Add("messages/schemas/TearDown-100-Schema.ps1.liquid"); documentmessage1.Resources.Add(messageresource1); var messageresource2 = new TargetResourceTemplate() { TemplateKey = "messagesAzureIntegrationAccountSchemaBTS2010FlatFilePipelineSampleNewOrder", TemplateType = "microsoft.template.json", ResourceName = "NewOrder", ResourceType = "microsoft.schemas.xml", OutputPath = "applications/BTS2010FlatFilePipelineSample/messages/neworder", }; messageresource2.Tags.Add("Application", "BTS2010FlatFilePipelineSample"); messageresource2.Tags.Add("Env", "dev"); messageresource2.Parameters.Add("azure_primary_region", "UK South"); messageresource2.Parameters.Add("azure_secondary_region", "West US"); messageresource2.Parameters.Add("azure_subscription_id", ""); messageresource2.Parameters.Add("azure_resource_group_name", "arrg-aimmsgbus-dev-uksouth"); messageresource2.Parameters.Add("azure_integration_account_name", "arintacc-aimartifactstore-dev-uksouth"); messageresource2.Parameters.Add("azure_message_schema_name", "BTS2010FlatFilePipelineSample.NewOrder"); messageresource2.ResourceTemplateFiles.Add("messages/schemas/requestbody.dev.json.liquid"); documentmessage1.Resources.Add(messageresource2); // Endpoints var ftpadapter1 = new AdapterEndpoint() { Type = MessagingObjectType.Endpoint, AdapterProtocol = "FTP", MessageExchangePattern = MessageExchangePattern.Receive, Name = "FTP Receive", Description = "FTP Receive Adapter", EndpointType = EndpointType.Adapter, MessageDeliveryGuarantee = MessageDeliveryGuarantee.AtLeastOnce, Activator = true, }; ftpadapter1.MessageKeyRefs.Add("MessageBus:BTS2010FlatFilePipelineSample:NewOrder"); ftpadapter1.OutputChannelKeyRef = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RcvFile.FTP-RoutingSlipRouter"; ftpadapter1.Properties.Add("scenario", "Aim.BizTalk.FTPPassthru.RcvFile.RcvFile.FTP"); ftpadapter1.Properties.Add("scenarioStep", "ftpReceiveAdapter"); ftpadapter1.Properties.Add("configuration", new Dictionary <string, object> { { "btsReceivePortName", "RcvFile" } }); ftpadapter1.ReportMessages.Add(new ReportMessage() { Severity = MessageSeverity.Error, Message = ModelResources.ExampleErrorMessage }); ftpadapter1.ReportMessages.Add(new ReportMessage() { Severity = MessageSeverity.Warning, Message = ModelResources.ExampleWarningMessage }); ftpadapter1.ReportMessages.Add(new ReportMessage() { Severity = MessageSeverity.Information, Message = ModelResources.ExampleInformationMessage }); application1.Endpoints.Add(ftpadapter1); var adapterresource1 = new TargetResourceTemplate() { TemplateKey = "deploySchemaBTS2010FlatFilePipelineSampleNewOrder", TemplateType = "microsoft.template.powershell", ResourceName = "NewOrder", ResourceType = "microsoft.scripts.powershell", OutputPath = "applications/BTS2010FlatFilePipelineSample/messages/neworder", }; adapterresource1.Parameters.Add("azure_primary_region", "UK South"); adapterresource1.Parameters.Add("azure_secondary_region", "West US"); adapterresource1.Parameters.Add("azure_subscription_id", ""); adapterresource1.Parameters.Add("azure_resource_group_name", "arrg-aimmsgbus-dev-uksouth"); adapterresource1.Parameters.Add("azure_integration_account_name", "arintacc-aimartifactstore-dev-uksouth"); adapterresource1.Parameters.Add("azure_message_schema_name", "BTS2010FlatFilePipelineSample.NewOrder"); adapterresource1.ResourceTemplateFiles.Add("messages/schemas/Deploy-100-Schema.ps1.liquid"); adapterresource1.ResourceTemplateFiles.Add("messages/schemas/New-Schema.ps1.liquid"); adapterresource1.ResourceTemplateFiles.Add("messages/schemas/Remove-Schema.ps1.liquid"); adapterresource1.ResourceTemplateFiles.Add("messages/schemas/TearDown-100-Schema.ps1.liquid"); ftpadapter1.Resources.Add(adapterresource1); var adapterresource2 = new TargetResourceTemplate() { TemplateKey = "messagesAzureIntegrationAccountSchemaBTS2010FlatFilePipelineSampleNewOrder", TemplateType = "microsoft.template.json", ResourceName = "NewOrder", ResourceType = "microsoft.schemas.xml", OutputPath = "applications/BTS2010FlatFilePipelineSample/messages/neworder", }; adapterresource2.Tags.Add("Application", "BTS2010FlatFilePipelineSample"); adapterresource2.Tags.Add("Env", "dev"); adapterresource2.Parameters.Add("azure_primary_region", "UK South"); adapterresource2.Parameters.Add("azure_secondary_region", "West US"); adapterresource2.Parameters.Add("azure_subscription_id", ""); adapterresource2.Parameters.Add("azure_resource_group_name", "arrg-aimmsgbus-dev-uksouth"); adapterresource2.Parameters.Add("azure_integration_account_name", "arintacc-aimartifactstore-dev-uksouth"); adapterresource2.Parameters.Add("azure_message_schema_name", "BTS2010FlatFilePipelineSample.NewOrder"); adapterresource2.ResourceTemplateFiles.Add("messages/schemas/requestbody.dev.json.liquid"); ftpadapter1.Resources.Add(adapterresource2); // Create the channel for the FTP adapter var channel1 = new TriggerChannel() { Type = MessagingObjectType.Channel, ChannelType = ChannelType.PointToPoint, Key = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RcvFile.FTP-RoutingSlipRouter", Name = "Trigger Channel", Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.RoutingSlipRouter intermediary.", }; application1.Channels.Add(channel1); var routingSlipRouter = new RoutingSlipRouter() { Type = MessagingObjectType.Intermediary, IntermediaryType = IntermediaryType.MessageRouter, MessageRouterType = MessageRouterType.ContentBasedRouter, Name = "Routing Slip Router", Key = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:RoutingSlipRouter:RcvFile.FTP-ContentPromoter", Description = "The routing slip router calls the next step in the route which is Content Promoter.", }; routingSlipRouter.InputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RcvFile.FTP-RoutingSlipRouter"); routingSlipRouter.OutputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter"); application1.Intermediaries.Add(routingSlipRouter); var channel2 = new TriggerChannel() { Type = MessagingObjectType.Channel, ChannelType = ChannelType.PointToPoint, Key = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter", Name = "Trigger Channel", Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.ContentPromoter intermediary.", TriggerUrl = "/routingManager/route/contentPromoter" }; application1.Channels.Add(channel2); var contentPromoter = new ContentPromoter() { Type = MessagingObjectType.Intermediary, IntermediaryType = IntermediaryType.MessageProcessor, MessageProcessorType = MessageProcessorType.ContentPromoter, }; contentPromoter.InputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter"); contentPromoter.OutputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:ContentPromoter-RoutingSlipRouter"); application1.Intermediaries.Add(contentPromoter); var channel3 = new TriggerChannel() { Type = MessagingObjectType.Channel, ChannelType = ChannelType.PointToPoint, Key = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:ContentPromoter-RoutingSlipRouter", Name = "Trigger Channel", Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.RoutingSlipRouter intermediary.", }; application1.Channels.Add(channel3); var routingSlipRouter2 = new RoutingSlipRouter() { Type = MessagingObjectType.Intermediary, IntermediaryType = IntermediaryType.MessageRouter, MessageRouterType = MessageRouterType.ContentBasedRouter, Name = "Routing Slip Router", Key = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:ContentPromoter", Description = "The routing slip router calls the next step in the route which is Content Promoter.", }; routingSlipRouter2.InputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter"); routingSlipRouter2.OutputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter"); application1.Intermediaries.Add(routingSlipRouter2); var channel4 = new TriggerChannel() { Type = MessagingObjectType.Channel, ChannelType = ChannelType.PointToPoint, Key = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter", Name = "Trigger Channel", Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.ContentPromoter intermediary.", TriggerUrl = "/routingManager/route/contentPromoter" }; application1.Channels.Add(channel4); var contentPromoter2 = new ContentPromoter() { Type = MessagingObjectType.Intermediary, IntermediaryType = IntermediaryType.MessageProcessor, MessageProcessorType = MessageProcessorType.ContentPromoter, Name = "Content Promoter", Key = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:ContentPromoter", }; contentPromoter2.InputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter"); contentPromoter2.OutputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter"); application1.Intermediaries.Add(contentPromoter2); var channel5 = new TriggerChannel() { Type = MessagingObjectType.Channel, ChannelType = ChannelType.PointToPoint, Key = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter", Name = "Trigger Channel", Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.ContentPromoter intermediary.", TriggerUrl = "/routingManager/route/contentPromoter" }; application1.Channels.Add(channel5); // System application var systemapp = new Application() { Name = "System Application", Key = "MessageBus:SystemApplication", Type = MessagingObjectType.Application, Description = "Azure Integration System Application", ResourceMapKey = "applicationSystemApplication", Rating = ConversionRating.NoRating, }; model.MigrationTarget.MessageBus.Applications.Add(systemapp); // Channels in the system application var topicchannel1 = new TopicChannel() { ChannelType = ChannelType.PublishSubscribe, Name = "Message Box", Key = "MessageBus:SystemApplication:MessageBox", Type = MessagingObjectType.Channel, Description = "Azure Integration Message Box", ResourceMapKey = "messageBox", Rating = ConversionRating.NotSupported }; systemapp.Channels.Add(topicchannel1); }
/// <summary> /// Binds the endpoint and intermediaries together. /// </summary> /// <param name="channelKeyPrefix">The prefix for the channel key.</param> /// <param name="activatorChannelKey">The key of the channel that hooks up to the activator intermediary.</param> /// <param name="targetApplication">The application in the target.</param> /// <param name="sendPort">The send port.</param> /// <param name="route">The chain of messaging objects that need to be bound by channels.</param> private void BindChannels(string channelKeyPrefix, string activatorChannelKey, Application targetApplication, SendPort sendPort, IList <MessagingObject> route) { _logger.LogDebug(TraceMessages.BindingChannelsForSendPort, RuleName, sendPort.Name); // Find topic channel to hook up the route var activatorChannel = Model.FindMessagingObject(activatorChannelKey); if (activatorChannel.application != null && activatorChannel.messagingObject != null) { // First object in route should be an activating intermediary, hook it up to the activator channel (if it's not an activator, it's a bug!) var activatorIntermediary = (Intermediary)route.First(); if (activatorIntermediary.Activator) { activatorIntermediary.InputChannelKeyRefs.Add(activatorChannel.messagingObject.Key); // Assume route is in order, that is, first entry is the start of the route. As the route is built // in this class, not expecting anything other than intermediaries and an endpoint. for (var i = 0; i < route.Count - 1; i++) { // Determine from and to steps var fromStep = route[i]; var toStep = route[i + 1]; // Create channel var channel = new TriggerChannel(MigrationTargetResources.TriggerChannelName) { Description = string.Format(CultureInfo.CurrentCulture, MigrationTargetResources.TriggerChannelDescription, toStep.Name), Key = $"{channelKeyPrefix}:{ModelConstants.TriggerChannelLeafKey}:{fromStep.Name.FormatKey()}-{toStep.Name.FormatKey()}", Rating = ConversionRating.FullConversion }; // Are we going from a routing slip router? if (fromStep is RoutingSlipRouter) { // Set URL var scenarioStep = toStep.Properties[ModelConstants.ScenarioStepName]; channel.TriggerUrl = $"/routingManager/route/{scenarioStep}"; // Label the channel appropriately channel.Properties.Add(ModelConstants.RouteLabel, MigrationTargetResources.RouteToChannelLabel); } else { // Label the channel appropriately channel.Properties.Add(ModelConstants.RouteLabel, MigrationTargetResources.RouteFromChannelLabel); } // Add channel to application targetApplication.Channels.Add(channel); // Bind channel with endpoint and intermediaries ((Intermediary)fromStep).OutputChannelKeyRefs.Add(channel.Key); if (toStep is Endpoint toEndpoint) { toEndpoint.InputChannelKeyRef = channel.Key; } if (toStep is Intermediary toIntermediary) { toIntermediary.InputChannelKeyRefs.Add(channel.Key); } } } else { var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.SendRouteStartNotAnActivator, activatorChannel.messagingObject.Name); _logger.LogError(error); Context.Errors.Add(new ErrorMessage(error)); } } else { var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindMessagingObjectWithKeyInTargetModel, MessagingObjectType.Channel, activatorChannelKey); _logger.LogError(error); Context.Errors.Add(new ErrorMessage(error)); } }