2

I've been playing with StreamInsight v2.3 and the newer Rx capabilities it provides. I'm investigating the use of SI for an Event Sourcing implementation. I've tweaked some of the MSDN sample code to get the following:

code for the server process:

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();
}

code for the client process:

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(); 
    }
}

Trying to run this produces the following error:

Reading from a remote 'System.Reactive.Linq.IQbservable`1[System.Int64]' is not supported. Use the 'Microsoft.ComplexEventProcessing.Linq.RemoteProvider.Bind' method to read from the source using a remote observer.

The sample code I started with defines an observer and sink and binds it in the StreamInsight server. I'm trying to keep the observer in the client process. Is there a way to set up an observer in the client app for a remote StreamInsight source? Does this have to be done through something like a WCF endpoint in the server that is observed by the client?

Richard
  • 133
  • 1
  • 6

1 Answers1

0

Actualy error is directing to the solution. You need 'bind' to the source.

Please check the snippet below:

//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");

Also note that, sink will run on server, not like I guessed at first that it will run on client. If you look to console apps for both server and client, console output is writing to server app.

If even there is a way to run sink on client, I don't know and I like to know that too.