StreamInsight:使用RemoteObservable的本地Observer

时间:2014-08-17 07:05:07

标签: c# system.reactive streaminsight

我一直在使用StreamInsight v2.3以及它提供的更新的Rx功能。我正在研究使用SI进行事件采购实施。我已经调整了一些MSDN sample code来获得以下内容:

服务器进程的代码:

using (var server = Server.Create("Default"))
{
    var host = new ServiceHost(server.CreateManagementService());
    host.AddServiceEndpoint(typeof(IManagementService), new WSHttpBinding(SecurityMode.Message), "http://localhost/SIDemo");
    host.Open();

    var myApp = server.CreateApplication("SIDemoApp");
    var mySource = myApp.DefineObservable(() => Observable.Interval(TimeSpan.FromSeconds(1))).ToPointStreamable(x => PointEvent.CreateInsert(DateTimeOffset.Now, x), AdvanceTimeSettings.StrictlyIncreasingStartTime); 
    mySource.Deploy("demoSource");

    Console.WriteLine("Hit enter to stop.");
    Console.ReadLine();

    host.Close();
}

客户端流程的代码:

using (var server = Server.Connect(new System.ServiceModel.EndpointAddress(@"http://localhost/SIDemo")))
{
    var myApp = server.Applications["SIDemoApp"];
    var mySource = myApp.GetObservable<long>("demoSource");

    using (var mySink = mySource.Subscribe(x => Console.WriteLine("Output - {0}", x)))
    {
        Console.WriteLine("Hit enter to stop.");
        Console.ReadLine(); 
    }
}

尝试运行此操作会产生以下错误:

  

从遥控器中读取   'System.Reactive.Linq.IQbservable`1 [System.Int64]'不受支持。   使用'Microsoft.ComplexEventProcessing.Linq.RemoteProvider.Bind'   使用远程观察者从源读取的方法。

我开始的示例代码定义了一个观察者并接收并将其绑定在StreamInsight服务器中。我试图让观察者保持在客户端进程中。有没有办法在客户端应用程序中为远程StreamInsight源设置观察者?这是否必须通过客户端观察到的服务器中的WCF端点来完成?

1 个答案:

答案 0 :(得分:0)

Actualy错误指向解决方案。你需要&#39; bind&#39;来源。

请查看以下代码段:

//Get SOURCE from server 
var serverSource = myApp.GetStreamable<long>("demoSource");

//SINK for 'demoSource'
var sinkToBind = myApp.DefineObserver<long>( ()=> Observer.Create<long>( value => Console.WriteLine( "From client : " + value)));

//BINDING 
var processForSink = serverSource.Bind(sinkToBind).Run("processForSink");

另请注意,接收器将在服务器上运行,而不是我最初猜到它将在客户端上运行。如果您希望控制服务器和客户端的应用程序,控制台输出正在写入服务器应用程序。

如果有一种方法可以在客户端运行接收器,我也不知道,我也想知道这一点。