private static Query CreateQuery(Application application, CepStream<BrandQuote> streamDefinition, BrandQuoteInputConfig inputConfig, BrandQuoteOutputConfig outputConfig) { var template = application.CreateQueryTemplate("QueryTemplate", null, streamDefinition); var binder = new QueryBinder(template); var inputAdapter = application.CreateInputAdapter<BrandQuoteInputAdapterFactory>("InputAdapter", null); binder.BindProducer("Input", inputAdapter, inputConfig, EventShape.Point); var outputAdapter = application.CreateOutputAdapter<BrandQuoteOutputAdapterFactory>("OutputAdapter", null); binder.AddConsumer("Output", outputAdapter, outputConfig, EventShape.Point, StreamEventOrder.FullyOrdered); var query = application.CreateQuery("Query", null, binder); return query; }
private void SetupStreamInsight() { using (var server = Server.Create("HomeStreamInsight")) { var application = server.CreateApplication("Application"); // Define a simple query CepStream<BrandQuote> input = CepStream<BrandQuote>.Create("Input"); var streamDefinition = from e in input select e; //where e.Premium % 10 == 0 // Bind query var inputConfig = new BrandQuoteInputConfig() { ListenToMassTransitOn= new Uri("rabbitmq://localhost/StreamInsightInputAdapter") }; var outputConfig = new BrandQuoteOutputConfig() { SendOnMassTransitFrom = new Uri("rabbitmq://localhost/StreamInsightOutputAdapter") }; Query query = CreateQuery(application, streamDefinition, inputConfig, outputConfig); query.Start(); signal.WaitOne(); query.Stop(); } }