Calling SSIS Package Asynchronously

I am calling an SSIS package using LoadPackage (...).

Is it possible to make this call an asynchronous call?

+1


source to share


4 answers


Yes, use an asynchronous delegate as shown here:



http://msdn.microsoft.com/en-us/library/h80ttd5f.aspx

+1


source


If you just want it to run in the background, then yes, you can either unwind the stream or call some T-SQL to dynamically create the job (and delete it again after that). If you want to run it asynchronously and want a callback when it's done, I think you're out of luck, unfortunately.



0


source


You are asking if it is 1) legal to call LoadPackage on a background thread or 2) it is possible. For # 1, I cannot give a definitive answer because I am not using the SSIS framework.

However, # 2 (as long as # 1 is true) is definitely doable. IMHO, you are better off using an existing framework that has an API designed to call the async API and expect results. For example, with the Parellel Extensions June 08 CTP, the following code will do.

using System.Threading.Tasks;
...
var future = Future.Create(()=>LoadPackage); // Starts loading the package
// Do other stuff
var package = future.Value;  // Wait for package load to complete and get the value

      

0


source


I am calling an SSIS package from my frontend (WPF) via a WCF async service call. Service code:

public string ImportMarriageXML(bool isWakeUp, bool clearExistingMarriage)
{
    try
    {
        var dts = new Microsoft.SqlServer.Dts.Runtime.Application();

        using (var package = dts.LoadFromSqlServer(
            ServiceSettings.Settings.SSIS.ImportMarriages,
            ServiceSettings.Settings.SSIS.ServerIP,
            ServiceSettings.Settings.SSIS.UserID,
            ServiceSettings.Settings.SSIS.Password,
            null))
        {
            package.InteractiveMode = false;
            package.Connections["DB.STAGING"].ConnectionString = String.Format("{0};Provider={1};", DBSettings.ConnectionString(Core.Database.Staging), ServiceSettings.Settings.SSIS.Provider);

            var variables = package.Variables;
            variables["IsWakeUp"].Value = isWakeUp;
            variables["ClearExistingMarriage"].Value = clearExistingMarriage;
            variables["XmlDirectory"].Value = ServiceSettings.Settings.SSIS.Properties.XmlDirectory;

            if (package.Execute() == DTSExecResult.Failure)
            {
                // HACK: Need to refactor this at some point. Will do for now.
                var errors = new System.Text.StringBuilder();
                foreach (var error in package.Errors)
                    errors.AppendFormat("SubComponent: {0}; Description: {1}{2}", error.SubComponent, error.Description, Environment.NewLine);
                throw new ApplicationException(errors.ToString());
            }

            return package.Connections["Text Logging"].ConnectionString;
        }
    }
}

      

And (part of) the client code looks like this:

private void InvokeLoadMarriages()
{
    integrationServicesServiceClient.BeginImportMarriageXML(false, OnEndImportMarriageXML, null);
}

private void OnEndImportMarriageXML(IAsyncResult asyncResult)
{
    view.InvokeDisplayResults(integrationServicesServiceClient.EndImportMarriageXML(asyncResult));
}

      

Where BeginImportMarriageXML and EndImportMarriageXML are the generated asynchronous operations in the proxy class.

0


source







All Articles