Beispiel #1
0
        public static void Main(string[] args)
        {
            var typeNameSerializer = new LegacyTypeNameSerializer();
            var argParser          = new ArgParser();
            var arguments          = argParser.Parse(args);

            bool enableBinaryPayloads = false;

            arguments.WithTypedKeyOptional <bool>("b", a => enableBinaryPayloads = bool.Parse(a.Value))
            .FailWith(messsage("Invalid enable binary payloads (b) parameter"));

            IErrorMessageSerializer errorMessageSerializer;

            if (enableBinaryPayloads)
            {
                errorMessageSerializer = new Base64ErrorMessageSerializer();
            }
            else
            {
                errorMessageSerializer = new DefaultErrorMessageSerializer();
            }

            // poor man's dependency injection FTW ;)
            var program = new Program(
                argParser,
                new QueueRetreival(errorMessageSerializer),
                new FileMessageWriter(),
                new MessageReader(),
                new QueueInsertion(errorMessageSerializer),
                new ErrorRetry(new JsonSerializer(), errorMessageSerializer),
                new Conventions(typeNameSerializer));

            program.Start(args);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            var typeNameSerializer = new TypeNameSerializer();
            var argParser = new ArgParser();
            var arguments = argParser.Parse(args);

            bool enableBinaryPayloads = false;
            arguments.WithTypedKeyOptional<bool>("b", a => enableBinaryPayloads = bool.Parse(a.Value))
                .FailWith(messsage("Invalid enable binary payloads (b) parameter"));

            IErrorMessageSerializer errorMessageSerializer;
            if (enableBinaryPayloads)
            {
                errorMessageSerializer = new Base64ErrorMessageSerializer();
            }
            else
            {
                errorMessageSerializer = new DefaultErrorMessageSerializer();
            }            

            // poor man's dependency injection FTW ;)            
            var program = new Program(
                argParser, 
                new QueueRetreival(errorMessageSerializer), 
                new FileMessageWriter(),
                new MessageReader(), 
                new QueueInsertion(errorMessageSerializer),
                new ErrorRetry(new JsonSerializer(typeNameSerializer), errorMessageSerializer),
                new Conventions(typeNameSerializer));
            program.Start(args);
        }
Beispiel #3
0
        public void Start(string[] args)
        {
            var arguments = argParser.Parse(args);

            var results   = new StringBuilder();
            var succeeded = true;
            Func <string, Action> messsage = m => () =>
            {
                results.AppendLine(m);
                succeeded = false;
            };

            var parameters = new QueueParameters();

            arguments.WithKey("s", a => parameters.HostName        = a.Value);
            arguments.WithKey("v", a => parameters.VHost           = a.Value);
            arguments.WithKey("u", a => parameters.Username        = a.Value);
            arguments.WithKey("p", a => parameters.Password        = a.Value);
            arguments.WithKey("o", a => parameters.MessageFilePath = a.Value);
            arguments.WithTypedKeyOptional <int>("n", a => parameters.NumberOfMessagesToRetrieve = int.Parse(a.Value))
            .FailWith(messsage("Invalid number of messages to retrieve"));

            try
            {
                arguments.At(0, "dump", () => arguments.WithKey("q", a =>
                {
                    parameters.QueueName = a.Value;
                    Dump(parameters);
                }).FailWith(messsage("No Queue Name given")));

                arguments.At(0, "insert", () => arguments.WithKey("q", a =>
                {
                    parameters.QueueName = a.Value;
                    Insert(parameters);
                }).FailWith(messsage("No Queue Name given")));

                arguments.At(0, "err", () => ErrorDump(parameters));

                arguments.At(0, "retry", () => Retry(parameters));

                arguments.At(0, "?", PrintUsage);

                // print usage if there are no arguments
                arguments.At(0, a => {}).FailWith(PrintUsage);
            }
            catch (EasyNetQHosepipeException easyNetQHosepipeException)
            {
                Console.WriteLine("Operation Failed:");
                Console.WriteLine(easyNetQHosepipeException.Message);
            }

            if (!succeeded)
            {
                Console.WriteLine("Operation failed");
                Console.Write(results.ToString());
                Console.WriteLine();
                PrintUsage();
            }
        }
Beispiel #4
0
        public void Start(string[] args)
        {
            var arguments = argParser.Parse(args);

            var parameters = new QueueParameters();

            arguments.WithKey("s", a => parameters.HostName  = a.Value);
            arguments.WithKey("sp", a => parameters.HostPort = Convert.ToInt32(a.Value));
            arguments.WithKey("v", a => parameters.VHost     = a.Value);
            arguments.WithKey("u", a => parameters.Username  = a.Value);
            arguments.WithKey("p", a => parameters.Password  = a.Value);
            arguments.WithKey("o", a => parameters.MessagesOutputDirectory = a.Value);
            arguments.WithKey("q", a => parameters.QueueName = a.Value);
            arguments.WithTypedKeyOptional <int>("n", a => parameters.NumberOfMessagesToRetrieve = int.Parse(a.Value))
            .FailWith(messsage("Invalid number of messages to retrieve"));
            arguments.WithTypedKeyOptional <bool>("x", a => parameters.Purge = bool.Parse(a.Value))
            .FailWith(messsage("Invalid purge (x) parameter"));

            try
            {
                arguments.At(0, "dump", () => arguments.WithKey("q", a =>
                {
                    parameters.QueueName = a.Value;
                    Dump(parameters);
                }).FailWith(messsage("No Queue Name given")));

                arguments.At(0, "insert", () => Insert(parameters));

                arguments.At(0, "err", () => ErrorDump(parameters));

                arguments.At(0, "retry", () => Retry(parameters));

                arguments.At(0, "?", PrintUsage);

                // print usage if there are no arguments
                arguments.At(0, a => {}).FailWith(PrintUsage);
            }
            catch (EasyNetQHosepipeException easyNetQHosepipeException)
            {
                Console.WriteLine("Operation Failed:");
                Console.WriteLine(easyNetQHosepipeException.Message);
            }

            if (!succeeded)
            {
                Console.WriteLine("Operation failed");
                Console.Write(results.ToString());
                Console.WriteLine();
                PrintUsage();
            }
        }