示例#1
0
        void RunForNumberOfBatches(int numberOfBatches, string streamName, KinesisDotNetProducer kinesisDotNetProducer)
        {
            for (int i = 0; i < numberOfBatches; i++)
            {
                if (i % 10000 == 0)
                {
                    log.info("started Sending user records with id = " + i);
                }

                kinesisDotNetProducer.AddUserRecord(streamName, "Partition" + i % 2, new MemoryStream(Encoding.UTF8.GetBytes(string.Format("This message # {0} is for Kinesis", i)))).Task.ContinueWith(LogCount);
                if (i % 40 == 0)
                {
                    Thread.Sleep(1);
                }
            }
        }
示例#2
0
        void AppStart()
        {
            KPLNETConfiguration config = new KPLNETConfiguration()
            {
                runAsDaemon         = false,
                nativeExecutable    = Properties.Settings.Default.DeamonAppPath,
                region              = AWSRegions.USWest2,
                aggregationMaxCount = 100,
                collectionMaxCount  = 100,
                logLevel            = log.LogLevel.ToString().ToLower()
            };

            KinesisDotNetProducer kinesisDotNetProducer = new KinesisDotNetProducer(log, config);

            string streamName = "KPLNETTest";

            while (true)
            {
                Console.WriteLine("Enter Number Of messages to add. Enter X to exit.");
                string uEntry = Console.ReadLine();
                if (uEntry.ToLower() == "x")
                {
                    break;
                }

                int batchesCount = 0;
                if (int.TryParse(uEntry, out batchesCount))
                {
                    RunForNumberOfBatches(batchesCount, streamName, kinesisDotNetProducer);
                }
                else
                {
                    Console.WriteLine("Invalid entry");
                }
            }
        }