I'm currently attemping to display the progress of an SSIS package that's running on the server by implementing a callback in WCF. This is working to a point; basically the OperationContext.Current is returning null after a few listener events have already happened (roughly 30 seconds after the initial SSIS package execute call). Here's some of the code that I'm using:
WCF Service method:
var dts = new Microsoft.SqlServer.Dts.Runtime.Application();
PackageEventListener listener = new PackageEventListener();
listener.OnPackageProgress += new PackageEventListener.PackageProgressChangedHandler(listener_OnPackageProgress);
...
if (package.Execute(null, null, listener, null, null) == DTSExecResult.Failure)
...
private static void listener_OnPackageProgress(object package, EventArgs packageinfo)
{
var context = System.ServiceModel.OperationContext.Current;
if (context == null) return;
IXLoadMarriageCallback callback = context.GetCallbackChannel<IXLoadMarriageCallback>();
if (callback != null)
{
PackageProgressEventArgs eventArgs = (PackageProgressEventArgs)packageinfo;
callback.OnProgressCallback(eventArgs.ProgressDescription);
}
}
public interface IXLoadMarriageCallback
{
[OperationContract(IsOneWay = true)]
void OnProgressCallback(string message);
}
(PackageEventListener is a class that inherits from Microsoft.SqlServer.Dts.Runtime.DefaultEvents)
The service is marked up as follows:
[ServiceBehavior(
InstanceContextMode = InstanceContextMode.PerSession,
ConcurrencyMode = ConcurrencyMode.Reentrant
)]
public class IntegrationServicesService : IIntegrationServicesService
And the service interface is marked up as follows:
[ServiceContract(
CallbackContract = typeof(Business.IXLoadMarriageCallback),
SessionMode = SessionMode.Required
)]
public interface IIntegrationServicesService
I'm using net tcp bindings, service-side config as follows:
<bindings>
<netTcpBinding>
<binding name="LongReliableTCPBinding"
closeTimeout="10:01:00" openTimeout="10:01:01" receiveTimeout="08:00:01" sendTimeout="08:00:02"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="4194304" maxBufferSize="4194304" maxConnections="10" maxReceivedMessageSize="4194304">
<readerQuotas maxDepth="32" maxStringContentLength="4194304" maxArrayLength="4194304" maxBytesPerRead="4194304" maxNameTableCharCount="4194304" />
<reliableSession ordered="true" inactivityTimeout="08:00:03" enabled="true" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
I can't see any exceptions being thrown. Apologies for the rather incomplete code sample as there's quite a lot going on (just to get an indication of progress!).
As requested, here's some of the client code that calls the service method (it's a presenter):
public class XLoadPresenter : IIntegrationServicesServiceCallback, IDisposable
{
private IXLoadView view;
private readonly IIntegrationServicesServiceClient integrationServicesServiceClient;
private readonly IXLoadServiceClient xloadServiceClient;
public XLoadPresenter(IXLoadServiceClient xloadServiceClient)
{
var context = new System.ServiceModel.InstanceContext(this);
this.integrationServicesServiceClient = new IntegrationServicesServiceClient(context);
this.xloadServiceClient = xloadServiceClient;
}
...
private void InvokeXLoadMarriages()
{
integrationServicesServiceClient.BeginXLoadMarriage(view.Database, OnEndXLoadMarriages, null);
}
...
}