Guest User

streaminsight

a guest
Jun 29th, 2011
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.ServiceModel;
  5.  
  6. using Microsoft.ComplexEventProcessing;
  7. using Microsoft.ComplexEventProcessing.Linq;
  8.  
  9. using StreamInsightLibrary;
  10. using StreamInsightPayLoad;
  11.  
  12. namespace StreamInsightApplication {
  13.     class Program {
  14.         static void Main(string[] args) {
  15.             Server server = Server.Connect(new EndpointAddress(@"http://localhost/StreamInsight/MyInstance"));
  16.             //var server = Server.Create("MyInstance");
  17.             if (server.Applications.ContainsKey("myHostApp")) {
  18.                 server.Applications["myHostApp"].Delete();
  19.             }
  20.             Application myApp = server.CreateApplication("myHostApp");
  21.             //Application myApp = myAppList["myHostApp"];
  22.  
  23.             var inputConfig = new StreamInsightInputConfig { QueueName = "testqueue" };
  24.             var outputConfig = new StreamInsightOutputConfig { Filepath = "C:\\Users\\pjain\\Desktop\\testFile.txt" };
  25.  
  26.             try {
  27.  
  28.                 CepStream<AnalyticsPayload> cepStream = CepStream<AnalyticsPayload>.Create("TaskLogStream", typeof(StreamInsightInputFactory), inputConfig, EventShape.Point);
  29.                 CepStream<AnalyticsPayload> filteredCepStream = from e in cepStream
  30.                                                                  select e;
  31.                 Query query = filteredCepStream.ToQuery(
  32.                 myApp,
  33.                 Guid.NewGuid().ToString(),
  34.                 "description",
  35.                 typeof(StreamInsightOutputFactory),
  36.                 outputConfig,
  37.                 EventShape.Point,
  38.                 StreamEventOrder.ChainOrdered);
  39.                 query.Start();
  40.                 Console.WriteLine("The query {0} is running for the application {1}", query.ShortName, myApp.ShortName);
  41.                 //Wait for Keystroke to end
  42.                 //Console.WriteLine("Press any key to stop the query stream and quit ........");
  43.                 //Console.ReadLine();
  44.                 query.Stop();
  45.  
  46.             } catch (Exception e) {
  47.                 Console.WriteLine(e.Message + e.StackTrace);
  48.             } finally {
  49.                 myApp.Delete();
  50.                 server.Dispose();
  51.  
  52.             }
  53.         }
  54.     }
  55. }
Add Comment
Please, Sign In to add comment