예제 #1
0
        /// <summary>
        /// Creates the options file for the java consumer
        /// </summary>
        /// <param name="options"></param>
        private static void WriteKCLPropertiesFile(KinesisConsumerOptions options)
        {
            //TODO: Check if the file exists. Potentially this will need to be removed once its complete
            var kclTemplate = new StreamReader(new MemoryStream(Resources.kcl_properties)).ReadToEnd();
            var kclFile     = string.Format(kclTemplate, options.ConsumerProgramCommandLine, options.StreamName, options.ApplicationName, options.StartPosition.ToString(), options.RegionName);

            File.WriteAllText(options.PropertiesFile, kclFile);
        }
예제 #2
0
        public static Process StartJavaSubscriptionProcess(KinesisConsumerOptions options)
        {
            options.PropertiesFile = string.Format("{0}.kcl.properties", options.StreamName.Replace(" ", "_"));



            string javaClassPath = FetchJars(options.JarFolder);

            string java = FindJava(options.JavaLocation);

            if (java == null)
            {
                System.Console.Error.WriteLine(
                    "java could not be found. You may need to install it, or manually specify the path to it.");

                Environment.Exit(2);
            }

            List <string> cmd = new List <string>()
            {
                java,
                "-cp",
                CleanFilePath(javaClassPath),
                "software.amazon.kinesis.multilang.MultiLangDaemon",
                "-p",
                options.PropertiesFile
            };

            if (!string.IsNullOrEmpty(options.LogbackConfiguration))
            {
                cmd.Add("-l");
                cmd.Add(options.LogbackConfiguration);
            }


            //Write the properties file before launching the process
            WriteKCLPropertiesFile(options);



            // Start the KCL.
            Process proc = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName        = cmd[0],
                    Arguments       = string.Join(" ", cmd.Skip(1)),
                    UseShellExecute = false
                }
            };

            proc.Start();

            return(proc);
        }