SSIS 脚本组件阻塞
Posted
技术标签:
【中文标题】SSIS 脚本组件阻塞【英文标题】:SSIS Script Component Blocking 【发布时间】:2020-11-06 18:40:39 【问题描述】:我有一个脚本转换作为数据流的一部分,它调用 Web 服务并将结果写入输出缓冲区以供稍后在管道中使用。由于某种原因,它就像一个阻塞组件一样,因为在处理完所有行之前,没有任何东西会退出组件。我的印象是脚本组件是同步的,因此是非阻塞的。我怀疑我必须在我的代码中做一些事情来导致这种情况,但试图确定它没有任何成功。
这是脚本:
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using SC_fbaeef4508eb4003b6e051eac81d22c3.net.integrationpoint.dps;
using System.Net;
using System.Xml;
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
private string username;
private string company;
private string password;
private string dtsSearchFlag;
private string CompanySync;
private int counter;
public override void PreExecute()
base.PreExecute();
//parameters - same for every row
company = Variables.Company;
username = Variables.UserName;
password = Variables.Password;
dtsSearchFlag = Variables.SearchFlag;
CompanySync = Variables.CompanySync;
counter = 0;
public override void Input0_ProcessInputRow(Input0Buffer Row)
try
//input columns
string companyId = Row.DPSCompanyID ;
string name = Row.DPSCompanyName ;
string address = Row.DPSAddress ;
string city = Row.DPSCity ;
string countryStateCode = Row.DPSState ;
string countryCode = Row.DPSCountryCode ;
string postalCode = Row.DPSPostalCode ;
//call webservice
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
DTSWebService service = new DTSWebService();
XmlNode result = service.DPSIntegratedSearch(company,
username,
password,
"", //loggedInUser
companyId,
"", //SearchType
"", //settingsDescription
name,
address,
city,
countryCode,
countryStateCode,
postalCode,
dtsSearchFlag,
"", //dtsLastValidatedDate
"", //dtsOverride
"", //dtsOverrideDate
"", //SearchRefNum
CompanySync
);
//get results
XmlNodeList nodes = result.SelectNodes("//search_status");
XmlNode node = nodes[0];
string resultGUID = node["result_guid"].InnerText;
string dtsSearchDate = node["dts_search_date"].InnerText;
string dtsMatch = node["dts_match"].InnerText;
string dtsLastValidatedDate = node["dts_last_validated_date"].InnerText;
string dtsOverride = node["dts_override"].InnerText;
string dtsOverrideDate = node["dts_override_date"].InnerText;
ushort hits = Convert.ToUInt16(node["num_hits"].InnerText);
//write to output
Row.ResultGUID = new Guid(resultGUID);
Row.SearchDate = Convert.ToDateTime(dtsSearchDate);
Row.Match = dtsMatch;
Row.LastValidatedDate = Convert.ToDateTime(dtsLastValidatedDate);
Row.Override = dtsOverride;
Row.OverrideDate = Convert.ToDateTime(dtsOverrideDate);
Row.NumHits = hits;
//counter (debug only)
counter++;
catch (Exception ex)
if (ex.InnerException != null)
OutputErrBuffer.ErrorMessage = ex.Message + " : " + ex.InnerException.InnerException.ToString().Substring(0, 3500) + " ...";
else if (ex.StackTrace != null)
OutputErrBuffer.ErrorMessage = ex.Message + " : " + (ex.StackTrace.Length > 3500 ? ex.StackTrace.ToString().Substring(0, 3500) + " ..." : ex.StackTrace.ToString().Substring(0, ex.StackTrace.Length));
else
OutputErrBuffer.ErrorMessage = ex.Message;
ComponentMetaData.FireWarning(1, "CallWebservice", "Exception calling webservice for AddressID:",null, 0);
这是行为:
【问题讨论】:
【参考方案1】:我实际上不确定它是否适用于转换,但是:
打开destination组件的属性对话框; 如果它的“数据访问模式”是Table or view - fast load
,那么您将可以访问“每批次的行数”属性。在这里,您可以指定组成单个批次的记录数量。
这个值至少会在数据流中传播并影响数据源。运气好的话,它也将应用于您的转换组件。
【讨论】:
好主意,但没有任何作用。以上是关于SSIS 脚本组件阻塞的主要内容,如果未能解决你的问题,请参考以下文章