Vũ Hoàng
Vũ Hoàng

Reputation: 265

Can I bind a query to an existing process of StreamInsight server?

I have StreamInsight Server

static void Main(string[] args)  
    {  
        // Create an embedded StreamInsight server  
        using (var server = Server.Create("Default"))  
        {  
            // Create a local end point for the server embedded in this program  
            var host = new ServiceHost(server.CreateManagementService());  
            host.AddServiceEndpoint(typeof(IManagementService), new WSHttpBinding(SecurityMode.Message), "http://localhost/MyStreamInsightServer");  
            host.Open();  

            /* The following entities will be defined and available in the server for other clients:  
             * serverApp  
             * serverSource  
             * serverSink  
             * serverProcess  
             */  

            // CREATE a StreamInsight APPLICATION in the server  
            var myApp = server.CreateApplication("serverApp");  

            // DEFINE a simple SOURCE (returns a point event every second)  
            var mySource = myApp.DefineObservable(() => Observable.Interval(TimeSpan.FromSeconds(1))).ToPointStreamable(x => PointEvent.CreateInsert(DateTimeOffset.Now, x), AdvanceTimeSettings.StrictlyIncreasingStartTime);  

            // DEPLOY the source to the server for clients to use  
            mySource.Deploy("serverSource");  

            // Compose a QUERY over the source (return every even-numbered event)  
            var myQuery = from e in mySource  
                          where e % 2 == 0  
                          select e;  

            // DEFINE a simple observer SINK (writes the value to the server console)  
            var mySink = myApp.DefineObserver(() => Observer.Create<long>(x => Console.WriteLine("sink_Server..: {0}", x)));  

            // DEPLOY the sink to the server for clients to use  
            mySink.Deploy("serverSink");  

            // BIND the query to the sink and RUN it  
            using (var proc = myQuery.Bind(mySink).Run("serverProcess"))  
            {  
                // Wait for the user stops the server  
                Console.WriteLine("----------------------------------------------------------------");  
                Console.WriteLine("MyStreamInsightServer is running, press Enter to stop the server");  
                Console.WriteLine("----------------------------------------------------------------");  
                Console.WriteLine(" ");  
                Console.ReadLine();  
            }  
            host.Close();  
        }  
    }  

And the StreamInsight Client A:

static void Main(string[] args)  
    {  
        // Connect to the StreamInsight server  
        using (var server = Server.Connect(new System.ServiceModel.EndpointAddress(@"http://localhost/MyStreamInsightServer")))  
        {  
            /* The following entities are expected to be defined in the server:  
             * serverApp0  
             * serverSource0  
             * serverSink0  
             */  
            /* The following entity will be defined in the server by this client:  
             * serverProcess_Client_A  
             */  

            // Get the existing StreamInsight APPLICATION  
            var myApp = server.Applications["serverApp"];  

            // GET the SOURCE from the server  
            var mySource = myApp.GetStreamable<long>("serverSource");  

            // Compose a QUERY on the source (return every even-numbered item + 1000)  
            var myQuery = from e in mySource  
                          where e % 2 == 0  
                          select e + 1000;  

            // GET the SINK from the server  
            var mySink = myApp.GetObserver<long>("serverSink");  

            // BIND the QUERY to the SINK and RUN it  
            using (var proc = myQuery.Bind(mySink).Run("serverProcess_Client_A"))  
            {  
                // Wait for the user to stop the program  
                Console.WriteLine("----------------------------------------------------------------");  
                Console.WriteLine("Client A is running, press Enter to exit the client");  
                Console.WriteLine("----------------------------------------------------------------");  
                Console.WriteLine(" ");  
                Console.ReadLine();  
            }  
        }  
    }

I have another client B and I want to bind a query of client B to this process of Client A (the process have name "serverProcess_Client_A"). I don't want create new process from client B

Question: Can I do that ?

Another question: Can I bind a query to an existing process of StreamInsight ?

Upvotes: 1

Views: 66

Answers (1)

QuangHao Ta
QuangHao Ta

Reputation: 76

It's impossible I think. Process name is unique for each client. If you use the same process for multiple clients then exception of "Process is existed" will be raised.

Upvotes: 1

Related Questions