Example #1
0
        public static Command CreateCommand()
        {
            var command = new Command("create", "Creates queues and exchanges for an endpoint based on a routing topology");

            var endpointNameArgument = new Argument <string>(
                name: "endpointName",
                description: "Specifies the name of the endpoint to create");

            var errorQueueOption = new Option <string>(
                name: "--errorQueueName",
                description: "Specifies that an error queue with the specified name should be created");

            var auditQueueOption = new Option <string>(
                name: "--auditQueueName",
                description: "Specifies that an audit queue with the specified name should be created");

            var instanceDiscriminatorsOption = new Option <IEnumerable <string> >(
                name: "--instanceDiscriminators",
                description: "Specifies a list of instance discriminators to use when the endpoint needs uniquely addressable instances")
            {
                Arity = ArgumentArity.ZeroOrMore,
                AllowMultipleArgumentsPerToken = true
            };

            var connectionFactoryBinder = SharedOptions.CreateConnectionFactoryBinderWithOptions(command);
            var routingTopologyBinder   = SharedOptions.CreateRoutingTopologyBinderWithOptions(command);

            command.AddArgument(endpointNameArgument);
            command.AddOption(errorQueueOption);
            command.AddOption(auditQueueOption);
            command.AddOption(instanceDiscriminatorsOption);

            command.SetHandler(async(endpointName, errorQueue, auditQueue, instanceDiscriminators, connectionFactory, routingTopology, console, cancellationToken) =>
            {
                var queueCreate = new EndpointCreateCommand(connectionFactory, routingTopology, console);
                await queueCreate.Run(endpointName, errorQueue, auditQueue, instanceDiscriminators, cancellationToken).ConfigureAwait(false);
            },
                               endpointNameArgument, errorQueueOption, auditQueueOption, instanceDiscriminatorsOption, connectionFactoryBinder, routingTopologyBinder, Bind.FromServiceProvider <IConsole>(), Bind.FromServiceProvider <CancellationToken>());

            return(command);
        }
Example #2
0
        public static Command CreateCommand()
        {
            var command = new Command("migrate", "Migrate in-flight delayed messages to the delay infrustructure v2.");

            var connectionFactoryBinder = SharedOptions.CreateConnectionFactoryBinderWithOptions(command);
            var routingTopologyBinder   = SharedOptions.CreateRoutingTopologyBinderWithOptions(command);

            var quietModeOption = new Option <bool>(name: "--Quiet", description: $"Disable console output while running");

            quietModeOption.AddAlias("-q");

            command.AddOption(quietModeOption);

            command.SetHandler(async(connectionFactory, routingTopology, quietMode, console, cancellationToken) =>
            {
                var delaysMigrate = new DelaysMigrateCommand(connectionFactory, routingTopology, quietMode, console);
                await delaysMigrate.Run(cancellationToken).ConfigureAwait(false);
            },
                               connectionFactoryBinder, routingTopologyBinder, quietModeOption, Bind.FromServiceProvider <IConsole>(), Bind.FromServiceProvider <CancellationToken>());

            return(command);
        }