Exemplo n.º 1
0
        public static KinesisClient GetKinesisClient(string region, string streamName, string accessKey, string secretKey, string appName)
        {
            if (_instance == null)
            {
                lock (SyncLock)
                {
                    if (_instance == null)
                    {
                        _instance = new KinesisClient(region, streamName, accessKey, secretKey, appName);
                    }
                }
            }

            return(_instance);
        }
Exemplo n.º 2
0
        private static async Task SendDataAsync(Options opts)
        {
            var userId = Guid.NewGuid().ToString();
            var amazonKinesisClient = new AmazonKinesisClient(Amazon.RegionEndpoint.GetBySystemName(opts.RegionEndpoint));
            var client = new KinesisClient(amazonKinesisClient, opts.StreamName);

            while (true)
            {
                var activity = GetNextActivity(userId);
                Console.Write($"Activity:{activity.ActivityType} ");
                await client.RecordAsync(activity, "test");

                Thread.Sleep(TimeSpan.FromMilliseconds(500));
            }
        }
Exemplo n.º 3
0
        public async static Task MainAsync(string[] args)
        {
            KinesisClient client = new KinesisClient("DemoApp", "us-east-1");

            var serializer = new JSONSerializer();
            var sender     = client.GetMessageSender <DemoAppEvent>("eventstream1", serializer, (m) => m.CustomerId.ToString());

            Random r = new Random();

            for (int x = 0; x < 10; x++)
            {
                var message = new DemoAppEvent {
                    CustomerId = r.Next(short.MaxValue), CustomerName = "Customer " + x.ToString(), OtherInfo = "Random other info"
                };
                Console.WriteLine(serializer.SerializeToString(message));
                await sender.SendMessageAsync(message);
            }

            Console.WriteLine();
            Console.WriteLine("all messages sent");
            Console.ReadLine();
        }