Esempio n. 1
0
        public void Run()
        {
            var data       = "{ \"Id\": 1, \"Data\": \"data\" }";
            var bytes      = Encoding.UTF8.GetBytes(data);
            var userRecord = new UserRecord("test", "1", bytes);

            var config = new KinesisProducerConfiguration
            {
                Region         = "eu-west-1",
                MaxConnections = 1,
            };

            IKinesisProducer kinesisProducer = new KinesisProducer(config);

            kinesisProducer.AddUserRecord(userRecord);
            kinesisProducer.FlushSync();

            var metrics = kinesisProducer.GetMetrics("UserRecordsPut", 10);

            foreach (var metric in metrics)
            {
                if (metric.Dimensions.Count == 1 && metric.SampleCount > 0)
                {
                    Console.WriteLine(metric.ToString());
                }
            }

            kinesisProducer.Destroy();
        }
        public AmazonFirehoseProducer(ILogger logger, IConfigurationManager config)
        {
            LogLevel kinesisLogLevel;

            try
            {
                kinesisLogLevel = (LogLevel)Enum.Parse(typeof(LogLevel), config.Get <string>("KinesisLogLevel"));
            }
            catch
            {
                kinesisLogLevel = LogLevel.Information;
            }

            var conf = new KinesisProducerConfiguration()
            {
                Region   = Environment.GetEnvironmentVariable("AWS_REGION"),
                LogLevel = kinesisLogLevel
            };

            _logger = logger;

            _kinesisProducer = new KinesisProducer(conf);

            _logger.Info($"{JsonConvert.SerializeObject(conf.CredentialsProvider.GetCredentials())}");
        }
        private KinesisProducer GetKinesisProducer()
        {
            var config = new KinesisProducerConfiguration
            {
                Region         = REGION,
                MaxConnections = 2,
                RequestTimeout = 60000L,
            };

            var producer = new KinesisProducer(config);

            return(producer);
        }
Esempio n. 4
0
        static void RunProducer()
        {
            var config = new KinesisProducerConfiguration
            {
                Region         = region,
                MaxConnections = 1,
            };

            var kinesisProducer = new KinesisProducer(config);

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine($"Writing record number {i}");

                var data       = $"Record {i}";
                var bytes      = Encoding.UTF8.GetBytes(data);
                var userRecord = new UserRecord(streamName, "partitionKey", bytes);

                kinesisProducer.AddUserRecord(userRecord);
            }

            kinesisProducer.FlushSync();
            kinesisProducer.Destroy();
        }