public override void Execute(Context context) { _catalog.Refresh(); string locationName = string.Format("ReceiveLocation-{0}", LocationName); // Location to remove is found in the test context if (!context.ContainsKey(locationName)) { throw new Exception(string.Format("{0} not found in the test context. You can only remove locations created by the ReceiveLocationCreateStep test step!", locationName)); } ReceiveLocation location = (ReceiveLocation)context.GetObject(locationName); context.LogInfo(string.Format("Remove receive location with name: '{0}', TransportType: '{1}', Address:'{2}', Pipeline:'{3}', Receive handler:'{4}'", location.Name, location.TransportType == null ? string.Empty : location.TransportType.Name, location.Address, location.ReceivePipeline == null ? string.Empty : location.ReceivePipeline.FullName, location.ReceiveHandler == null ? string.Empty : location.ReceiveHandler.Name)); ReceivePort port = _catalog.ReceivePorts[location.ReceivePort.Name]; _catalog.RemoveReceivePort(port); _catalog.SaveChanges(); }
void SaveTopic() { //var bce = CatalogExplorerFactory.CatalogExplorer(); try { //bce.ConnectionString = CatalogExplorerFactory.CatalogExplorer().ConnectionString; ReceiveLocation rl = null; foreach (ReceivePort port in CatalogExplorerFactory.CatalogExplorer().Applications[appName].ReceivePorts) { foreach (ReceiveLocation rloc in port.ReceiveLocations) { if (!rloc.Name.Equals(recLocName)) { continue; } rl = rloc; break; } } root = CreateDeveloperConceptualElement(); if (null == rl) { return; } tokenId = CleanAndPrep(appName + ".ReceiveLocations." + rl.ReceivePort.Name + rl.Name); TokenFile.GetTokenFile().AddTopicToken(tokenId, id); var intro = new XElement(xmlns + "introduction", new XElement(xmlns + "para", new XText(string.IsNullOrEmpty(rl.Description) ? "No description was available for this receive location." : rl.Description))); var section = new XElement(xmlns + "section", new XElement(xmlns + "title", new XText("Receive Location Properties")), new XElement(xmlns + "content", new XElement(xmlns + "table", new XElement(xmlns + "tableHeader", new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Property")), new XElement(xmlns + "entry", new XText("Value")))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Address")), new XElement(xmlns + "entry", new XText(string.IsNullOrEmpty(rl.Address) ? "N/A" : rl.Address))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Custom Data")), new XElement(xmlns + "entry", new XText(string.IsNullOrEmpty(rl.CustomData) ? "N/A" : rl.CustomData))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Enabled")), new XElement(xmlns + "entry", new XText(rl.Enable.ToString()))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("End Date")), new XElement(xmlns + "entry", new XText(rl.EndDate.ToString()))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("End Date Enabled")), new XElement(xmlns + "entry", new XText(rl.EndDateEnabled.ToString()))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Fragment Messages")), new XElement(xmlns + "entry", new XText(rl.FragmentMessages.ToString()))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("From Time")), new XElement(xmlns + "entry", new XText(rl.FromTime.ToString()))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Public Address")), new XElement(xmlns + "entry", new XText(string.IsNullOrEmpty(rl.PublicAddress) ? "N/A" : rl.PublicAddress))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Receive Handler Transport")), new XElement(xmlns + "entry", new XText(null == rl.ReceiveHandler ? "N/A" : rl.ReceiveHandler.TransportType.Name))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Receive Pipeline")), GetPipelineEntry(rl.ReceivePipeline)), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Receive Pipeline Data")), new XElement(xmlns + "entry", new XText(string.IsNullOrEmpty(rl.ReceivePipelineData) ? "N/A" : rl.ReceivePipelineData))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Receive Port")), new XElement(xmlns + "entry", new XElement(xmlns + "token", new XText(CleanAndPrep(appName + ".ReceivePorts." + rl.ReceivePort.Name))))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Send Pipeline")), GetPipelineEntry(rl.SendPipeline)), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Send Pipeline Data")), new XElement(xmlns + "entry", new XText(string.IsNullOrEmpty(rl.SendPipelineData) ? "N/A" : rl.SendPipelineData))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Service Window Enabled")), new XElement(xmlns + "entry", new XText(rl.ServiceWindowEnabled.ToString()))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Start Date")), new XElement(xmlns + "entry", new XText(rl.StartDate.ToString()))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Start Date Enabled")), new XElement(xmlns + "entry", new XText(rl.StartDateEnabled.ToString()))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Transport Type Name")), new XElement(xmlns + "entry", new XText(null == rl.TransportType ? "N/A" : rl.TransportType.Name))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Transport Type Capabilities")), new XElement(xmlns + "entry", new XText(null == rl.TransportType ? "N/A" : rl.TransportType.Capabilities.ToString()))), new XElement(xmlns + "row", new XElement(xmlns + "entry", new XText("Transport Type Data")), new XElement(xmlns + "entry", new XText(string.IsNullOrEmpty(rl.TransportTypeData) ? "N/A" : rl.TransportTypeData))) ))); root.Add(intro, section); if (doc.Root != null) { doc.Root.Add(root); } } catch (Exception ex) { HandleException("ReceiveLocationTopic.DoWork", ex); } }
private MessagingObject CreateReceiveEndpoint(string endpointKeyPrefix, ResourceItem sourceApplication, Application targetApplication, ReceivePort receivePort, ReceiveLocation receiveLocation) #pragma warning restore CA1801 { _logger.LogDebug(TraceMessages.CreatingReceiveEndpointAdapter, RuleName, receiveLocation.ReceiveLocationTransportType.Name, receiveLocation.Name); // Create an endpoint adapter (assume receive-response or receive, but some adapters may be accept which will be changed later by a specific rule) var endpointAdapter = new AdapterEndpoint(receiveLocation.Name, receiveLocation.ReceiveLocationTransportType.Name) { Activator = true, Description = receiveLocation.Description, Key = $"{endpointKeyPrefix}:{ModelConstants.AdapterEndpointLeafKey}", MessageDeliveryGuarantee = MessageDeliveryGuarantee.AtLeastOnce, MessageExchangePattern = receivePort.IsTwoWay ? MessageExchangePattern.ReceiveResponse : MessageExchangePattern.Receive }; // TODO: Add schema references from source application // By default, this isn't convertible unless overridden by a specific rule endpointAdapter.Rating = ConversionRating.NoAutomaticConversion; // Set scenario and step name as properties on the endpoint var scenarioName = $"{targetApplication.Name.FormatKey()}.{receivePort.Name.FormatKey()}.{receiveLocation.Name.FormatKey()}"; endpointAdapter.Properties.Add(ModelConstants.ScenarioName, scenarioName); endpointAdapter.Properties.Add(ModelConstants.ScenarioStepName, $"{receiveLocation.ReceiveLocationTransportType.Name.ToLowerInvariant()}ReceiveAdapter"); // Set BizTalk specific configuration properties var configurationEntries = new Dictionary <string, object>() { { ModelConstants.IsTwoWay, receivePort.IsTwoWay }, { ModelConstants.BizTalkReceivePortName, receivePort.Name }, { ModelConstants.BizTalkReceivePortId, $"{targetApplication.Name.FormatKey()}.{receivePort.Name.FormatKey()}" }, { ModelConstants.BizTalkInboundTransportType, receiveLocation.ReceiveLocationTransportType.Name }, { ModelConstants.BizTalkInboundTransportLocation, receiveLocation.Address }, { ModelConstants.FailedMessageRouting, true } }; // Is it a two-way port? if (receivePort.IsTwoWay) { configurationEntries.Add(ModelConstants.ResponseTimeout, 20); } // Add configuration properties endpointAdapter.Properties.Add(ModelConstants.ConfigurationEntry, configurationEntries); // Set BizTalk specific routing properties var routingProperties = new Dictionary <string, object>() { { ModelConstants.BizTalkReceivePortName, ModelConstants.BizTalkReceivePortName }, { ModelConstants.BizTalkReceivePortId, ModelConstants.BizTalkReceivePortId }, { ModelConstants.BizTalkInboundTransportType, ModelConstants.BizTalkInboundTransportType }, { ModelConstants.BizTalkInboundTransportLocation, ModelConstants.BizTalkInboundTransportLocation } }; // Add routing properties endpointAdapter.Properties.Add(ModelConstants.RoutingProperties, routingProperties); // Add response topic subscription if (receivePort.IsTwoWay) { CreateEndpointFilter(endpointAdapter, receivePort); } return(endpointAdapter); }
/// <summary> /// Builds a new route for interchange handling where recoverable interchange processing is set to false, meaning /// the batch must atomically succeed or fail as a unit, rather than an individual messages. /// </summary> /// <param name="intermediaryKeyPrefix">The prefix for the intermediary key.</param> /// <param name="targetApplication">The application in the target.</param> /// <param name="receivePort">The receive port.</param> /// <param name="receiveLocation">The receive location.</param> private void BuildInterchangeAggregationRoute(string intermediaryKeyPrefix, Application targetApplication, ReceivePort receivePort, ReceiveLocation receiveLocation) { _logger.LogDebug(TraceMessages.BuildingNewRouteForInterchangeHandling, RuleName); // Find interchange queue channel var interchangeQueueChannelKey = $"{ModelConstants.MessageBusLeafKey}:{ModelConstants.SystemApplicationLeafKey}:{ModelConstants.InterchangeQueueLeafKey}"; var messagingObject = Model.FindMessagingObject(interchangeQueueChannelKey); if (messagingObject.messagingObject != null) { _logger.LogDebug(TraceMessages.CreatingInterchangeAggregatorIntermediary, RuleName, MigrationTargetResources.InterchangeAggregatorName); var route = new List <MessagingObject>(); // Create an intermediary based on the aggregator var aggregatorIntermediary = new Aggregator(MigrationTargetResources.InterchangeAggregatorName) { Activator = true, Description = MigrationTargetResources.InterchangeAggregatorDescription, Key = $"{intermediaryKeyPrefix}:{ModelConstants.InterchangeAggregatorLeafKey}", Rating = ConversionRating.NoAutomaticConversion }; var scenarioName = $"{targetApplication.Name.FormatKey()}.{receivePort.Name.FormatKey()}.{receiveLocation.Name.FormatKey()}.{ModelConstants.InterchangeAggregatorLeafKey}"; aggregatorIntermediary.Properties.Add(ModelConstants.ScenarioName, scenarioName); aggregatorIntermediary.Properties.Add(ModelConstants.ScenarioStepName, "interchangeAggregator"); aggregatorIntermediary.Properties.Add(ModelConstants.ConfigurationEntry, new Dictionary <string, object>()); aggregatorIntermediary.Properties.Add(ModelConstants.RoutingProperties, new Dictionary <string, object>()); // Hook aggregator up to interchange queue aggregatorIntermediary.InputChannelKeyRefs.Add(interchangeQueueChannelKey); route.Add(aggregatorIntermediary); _logger.LogDebug(TraceMessages.CreatingInterchangeSplitterIntermediary, RuleName, MigrationTargetResources.InterchangeSplitterName); // Create an intermediary based on the splitter var splitterIntermediary = new Splitter(MigrationTargetResources.InterchangeSplitterName) { Description = MigrationTargetResources.InterchangeSplitterDescription, Key = $"{intermediaryKeyPrefix}:{ModelConstants.InterchangeSplitterLeafKey}", Rating = ConversionRating.NoAutomaticConversion }; splitterIntermediary.Properties.Add(ModelConstants.ScenarioStepName, "interchangeSplitter"); splitterIntermediary.Properties.Add(ModelConstants.ConfigurationEntry, new Dictionary <string, object>()); splitterIntermediary.Properties.Add(ModelConstants.RoutingProperties, new Dictionary <string, object>()); route.Add(splitterIntermediary); // Create the message agent intermediaries route.AddRange(CreateMessageAgentIntermediaries(intermediaryKeyPrefix, _messageBoxChannelKey, false, null)); // Binds the route by adding routing slip router intermediaries between the intermediaries in the receive port var boundRoute = BindRoute(intermediaryKeyPrefix, targetApplication, receivePort, route); // Binds the channels between the endpoint and intermediaries up to the message box (topic channel) BindChannels(intermediaryKeyPrefix, targetApplication, receivePort, boundRoute); } else { var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindMessagingObjectWithKeyInTargetModel, MessagingObjectType.Channel, interchangeQueueChannelKey); _logger.LogError(error); Context.Errors.Add(new ErrorMessage(error)); } }
public IEnumerable <ReceiveLocation> Get() { List <ReceiveLocation> receiveLocations = new List <ReceiveLocation>(); try { //Create EnumerationOptions and run wql query EnumerationOptions enumOptions = new EnumerationOptions(); enumOptions.ReturnImmediately = false; //Search for DB servername and trackingDB name ManagementObjectSearcher searchObject = new ManagementObjectSearcher("root\\MicrosoftBizTalkServer", "Select TrackingDBServerName, TrackingDBName from MSBTS_GroupSetting", enumOptions); ManagementObjectCollection searchCollection = searchObject.Get(); ManagementObject obj = searchCollection.OfType <ManagementObject>().FirstOrDefault(); string connectionString = "Server=" + obj["TrackingDBServerName"] + ";Database=" + obj["TrackingDBName"] + ";Integrated Security=True;"; string query = @"select A.nvcName [ApplicationName]" + ",RP.nvcName [ReceivePortName] " + ",RL.Name [ReceiveLocationName] " + ",RL.Disabled [Disabled] " + ",MAX(MF.[Event/Timestamp]) [LastMessageReceivedDateTime] " + "FROM " + "BizTalkMgmtDb.dbo.adm_ReceiveLocation RL " + "JOIN BizTalkMgmtDb.dbo.bts_receiveport RP ON RP.nID = RL.ReceivePortId " + "LEFT OUTER JOIN BizTalkDTADb.dbo.dtav_MessageFacts MF ON MF.[Event/Port] = RP.nvcName " + "AND MF.[Event/URL] = RL.InboundTransportURL " + "JOIN BizTalkMgmtDb.dbo.bts_application A ON RP.nApplicationID = A.nID " + "group by A.nvcName, RP.nvcName, RL.Name, RL.Disabled;"; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { ReceiveLocation receiveLocation = new ReceiveLocation(); receiveLocation.ApplicationName = (string)reader["ApplicationName"]; receiveLocation.ReceivePortName = (string)reader["ReceivePortName"]; receiveLocation.ReceiveLocationName = (string)reader["ReceiveLocationName"]; receiveLocation.Disabled = (int)reader["Disabled"] == 0 ? false : true; if (reader["LastMessageReceivedDateTime"] != DBNull.Value) { receiveLocation.LastMessageReceivedDateTime = (DateTime)reader["LastMessageReceivedDateTime"]; } receiveLocations.Add(receiveLocation); } } finally { // Always call Close when done reading. reader.Close(); } } } catch (Exception ex) { throw new Exception("Exception Occurred in get receivelocations call. " + ex.Message); } return(receiveLocations); }
static void CreateAndConfigureReceiveLocation() { BtsCatalogExplorer root = new BtsCatalogExplorer(); try { root.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;"; //First, create a new one way receive port. ReceivePort myreceivePort = root.AddNewReceivePort(false); //Note that if you dont set the name property for the receieve port, //it will create a new receive location and add it to the receive //port. myreceivePort.Name = "My Receive Port"; //Create a new receive location and add it to the receive port ReceiveLocation myreceiveLocation = myreceivePort.AddNewReceiveLocation(); foreach (ReceiveHandler handler in root.ReceiveHandlers) { if (handler.TransportType.Name == "HTTP") { myreceiveLocation.ReceiveHandler = handler; break; } } //Associate a transport protocol and URI with the receive location. foreach (ProtocolType protocol in root.ProtocolTypes) { if (protocol.Name == "HTTP") { myreceiveLocation.TransportType = protocol; break; } } myreceiveLocation.Address = "/home"; //Assign the first receive pipeline found to process the message. foreach (Pipeline pipeline in root.Pipelines) { if (pipeline.Type == PipelineType.Receive) { myreceiveLocation.ReceivePipeline = pipeline; break; } } //Enable the receive location. myreceiveLocation.Enable = true; myreceiveLocation.FragmentMessages = Fragmentation.Yes; //optional property myreceiveLocation.ServiceWindowEnabled = false; //optional property //Try to commit the changes made so far. If the commit fails, //roll-back all changes. root.SaveChanges(); } catch (Exception e) { root.DiscardChanges(); throw e; } }
public static string Id(this ReceiveLocation omReceiveLocation) { return(omReceiveLocation.Name); }